Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm trying to run loop for every single record based on start month and end month in table. The data should be added in new line for every month.
Source Table:
ID | Start Month | End Month | Amount |
1 | 202301 | 202303 | 10 |
2 | 202304 | 202306 | 20 |
I need to get something like
ID | Start Month | End Month | Month | Amount |
1 | 202301 | 202303 | 202301 | 10 |
1 | 202301 | 202303 | 202302 | 10 |
1 | 202301 | 202303 | 202303 | 10 |
2 | 202304 | 202306 | 202304 | 20 |
2 | 202304 | 202306 | 202305 | 20 |
2 | 202304 | 202306 | 202306 | 20 |
Something along the lines of:
Load ID, StartMonth, EndMonth, StartMonth + IterNo() - 1 as Month, Amount
From YourTable
While StartMonth + IterNo() -1 <= EndMonth;
Thanks for the answer. Have achieved this with Intervalmatch function