Query to merge continuous temporal records
I have a table like this:
I want to merge the records where the start_date is just next day of end_date of another record: So the end record should be something like this:
One way that I know to do this will be to create a row based temp table with various rows as dates (each record for one date, between the total range of days) and thus making the table flat.
But there has to be a cleaner way to do this in a single query… e.g. something using row_num?
You can use a numbers table instead of using