Skip to content
Advertisement

recursively creating multiple rows for every date between two dates in one row

I have staff holidays (rdos) stored in a single row, I am very close to recursively expanding them to show a full row for each day of leave. Running this on Postgres Database version 10.10

Data Set:

My query currently:

I am getting duplicate regressions and unwanted cross matches.

Any ideas? I have seen similar solutions that rely on a unioned table of the months, but i don’t know if that would apply here.

Advertisement

Answer

No need for a recursive query to achieve such task In Postgres: you can just use generate_series() and a lateral join:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement