til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as a developer

View project on GitHub

How to group by month in a year

Sometimes you are requested to give a swift overview or statistic of how something evolves (or devolves) over time.

This query uses Oracle specific syntax, but this overall structure should be applicable in other SQL dialects.

select to_char(DATE_CREATED, 'YYYY-MM'), sum(something_we_can_count_on)
from our_table
group by to_char(DATE_CREATED, 'YYYY-MM')
order by 1

References