I have this table that lists which months each product is available on the market. For example product 1 is available from Mar to Dec and product 2 is available from Jan to Feb.
| product_id | start_month | end_month |
|---|---|---|
| 1 | 3 | 12 |
| 2 | 1 | 2 |
| 3 | 4 | 6 |
| 4 | 4 | 8 |
| 5 | 5 | 5 |
| 6 | 10 | 11 |
I need to count how many product_ids each month of the year has but can't think of how to put: WHERE month >= start_month AND month >= end_month. Can I use a loop for this or would that be overkill>