I need to create a row for every month (result should be first day of the month) between 2 dates for each person in my table. For example, if I have the following data in my source table:
rowID | person | startdate | enddate
1 | 12345 | 2014-04-01 | 2014-11-30
2 | 67890 | 2014-03-01 | 2014-05-01
I want the results in my destination table to be:
person | month
12345 | 2014-04-01
12345 | 2014-05-01
12345 | 2014-06-01
12345 | 2014-07-01
12345 | 2014-08-01
12345 | 2014-09-01
12345 | 2014-10-01
12345 | 2014-11-01
67890 | 2014-03-01
67890 | 2014-04-01
67890 | 2014-05-01
Thanks so much for the help.
No need for a CTE or a lateral join: