I'm trying to work out how to select a row for each month between a period. The period will have a start date of the earliest month within the table. So in the example below the start period will be 2016-01-01, but the end period will be user defined, lets say 2017-02-01. My table:
rowID | Month | someDate | SomeOtherDate | Number
1 | 2016-01-01 | 2018-01-01 | 2018-01-01 | 0
2 | 2016-07-01 | 2019-03-01 | 2019-02-01 | 1
The result I'm looking for is this:
Month | someDate | SomeOtherDate | Number
2016-01-01 | 2018-01-01 | 2018-01-01 | 0
2016-02-01 | 2018-01-01 | 2018-01-01 | 0
2016-03-01 | 2018-01-01 | 2018-01-01 | 0
2016-04-01 | 2018-01-01 | 2018-01-01 | 0
2016-05-01 | 2018-01-01 | 2018-01-01 | 0
2016-05-01 | 2018-01-01 | 2018-01-01 | 0
2016-07-01 | 2019-03-01 | 2019-02-01 | 1
2016-08-01 | 2019-03-01 | 2019-02-01 | 1
2016-09-01 | 2019-03-01 | 2019-02-01 | 1
2016-10-01 | 2019-03-01 | 2019-02-01 | 1
2016-11-01 | 2019-03-01 | 2019-02-01 | 1
2016-12-01 | 2019-03-01 | 2019-02-01 | 1
2017-01-01 | 2019-03-01 | 2019-02-01 | 1
2017-02-01 | 2019-03-01 | 2019-02-01 | 1
Essentially I need to duplicate the row until it finds another row or meets the period end date, if another row is found then duplicate that row until the end period is met, while incrementing the Month for each row. Hope that makes sense.
Any help would be greatly appreciated.