Skip to content
Advertisement

Returning non-overlapping records within a date range

I have the following data. I have looked over a lot of threads about overlapping and non-overlapping dates but none seemed to help me.

From this table with a SQL query I want to return the first record out of overlapping dates or basically

I have been struggling a lot with this query and was wondering if this is actually possible without too much of a hit on performance and whether its better if thats done on backend or with a SQL query because I believe it’d be easier for me to do it on the backend.

Advertisement

Answer

This can be achieved by creating a new column and partitioning it to fetch only first rows.

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