Reputation: 7163
I have a column 'last_updated' in an mssql table and I want to select the months only from the column and have count of how many individual months there are:
24/09/2011 22:34:20
24/09/2011 22:35:50
15/10/2011 14:06:43
15/09/2011 18:42:32
18/10/2011 00:37:41
So in above column you would have
Month | Occurances
9 | 3
10 | 2
Any ideas how I can extract that info?
Upvotes: 2
Views: 2985
Reputation: 17570
SELECT MONTH(DateColumn) AS MonthNumber, COUNT(1) AS Occurances
FROM schema.TableName
GROUP BY MONTH(DateColumn)
Upvotes: 2