I have a table my_table that resembles:
id start_date end_date
1 2019-12 2021-12
2 2017-11 2019-03
3 2016-09 2018-09
I have another table date_values with every date like:
date_value
2016-09
2016-10
I want to get the output for every month:
month num_people
2016-09 1
2016-10 1
How would I go about doing this?
I know I would need to GROUP BY month and then aggregate by COUNT(id), but I'm unsure of how to get the dates in the format I need. Would appreciate help, thanks!