I have the following MySQL-Database-Table with subscriptions. Each subscription as a startdate and an enddate.
id | start_date | end_date
1 | 2017-01-01 | 2017-07-01
2 | 2017-01-15 | 2017-07-12
3 | 2017-02-01 | 2017-08-01
4 | 2017-03-01 | 2017-08-01
5 | 2017-03-12 | 2017-08-12
6 | 2017-03-30 | 2017-08-30
7 | 2017-05-01 | 2017-11-01
8 | 2017-06-01 | 2017-12-01
9 | 2017-07-01 | 2018-01-01
10 | 2017-08-01 | 2018-02-01
11 | 2018-01-01 | 2018-07-01
12 | 2018-02-01 | 2018-08-01
13 | 2018-03-01 | 2018-09-01
... | ... | ...
I would like to select all active subscritions within each month. Is this possible with one SQL-Query? I would like to know: How many acitve subscriptions there were in January, February, March, etc. For example the query for just June 2017 would be:
SELECT COUNT(*) FROM table
WHERE start_date <= '2017-06-30' AND
end_date >= '2017-06-01'
I hope my text is understandable.