Skip to content
Advertisement

SQL Date range by month returns in multiple rows

I am looking to get the count of entries by the month. However, this is returning the total count.

I would like it to be something like.

Month —– Count

January —- 500

February —- 600

If I can’t get the month in there, thats fine, but I would definitely like to have it so the count has its own row. How is something like that achieved?

Advertisement

Answer

That’s a straight aggregation query, where you want to count how many records exist for each month.

You can do:

The first column gives you the first day of the month for which data was aggregated – which seems more relevant that just the month name.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement