I have the following data, as an example:
Name | Value | startdate | enddate
1 | 10 | 2023-04-01 | 2023-06-30
2 | 99 | 2023-03-01 | 2023-05-01
I need to get the following output:
Name | Value | date
1 | 10 | 2023-04
1 | 10 | 2023-05
1 | 10 | 2023-06
2 | 99 | 2023-03
2 | 99 | 2023-04
2 | 99 | 2023-05
Which, in resume, is a new row with the same Value for every month between the date range for every Name column.
Tried some solutions seen here and here, but didn't turned out so great, since it's not the same expected result, and sometimes having the startDate on 2022 and EndDate on 2023 for example breaks some mentioned solutions.
What I made so far:
SELECT
value,
DATE_FORMAT(startdate, "%Y-%m") AS startMonth,
DATE_FORMAT(enddate, "%Y-%m") AS endMonth
FROM
table
GROUP BY
--Here's my stuggle
A procedure would help too! As long as it generates that output.