amachin
amachin

Reputation: 27

How to count occurences of a certain date in a new column?

I have two columns that shows a list of account numbers and the month the account opened, like below:

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

I need to create a query to sums up the total number of accounts opened for each month. So the results should come out like this:

Oct 3
Nov 2
Dec 1
Jan 2

Upvotes: 1

Views: 60

Answers (3)

yuvi
yuvi

Reputation: 574

Select Month,
count(Account) as totalcounts from table
group by Month;

Upvotes: 3

kavetiraviteja
kavetiraviteja

Reputation: 2208

Select Month,count(Account) as cntOfaccounts from tableName 
       group by Month;

Upvotes: 1

SQL Police
SQL Police

Reputation: 4196

This is the principle:

select [Month], count(Account) 
from t 
group by [Month];

Upvotes: 1

Related Questions