2015-06-30 59 views
1

我有两列,显示帐号和当月账户开设,像下面的列表:如何计算新列中某个日期的出现次数?

Account Month 
NEW021 Oct 
EVA329 Nov 
VEP005 Oct 
CIT410 Dec 
COE210 Oct 
BAR023 Jan 
HOW234 Jan 

我需要创建一个查询,总结了账户总数打开每个月。这样的成绩应该出来是这样的:

Oct 3 
Nov 2 
Dec 1 
Jan 2 
+2

看一看[GROUP BY](HTTP://www.w3schools。 COM/SQL/sql_groupby.asp) –

回答

1

这是原则:

select [Month], count(Account) 
from t 
group by [Month]; 
1
Select Month,count(Account) as cntOfaccounts from tableName 
     group by Month; 
3
Select Month, 
count(Account) as totalcounts from table 
group by Month; 
相关问题