Skip to content

Tag: oracle

Aggregate rows based on MIN flag

I’m thinking this is an easy one but the answer is escaping me. Example: I have a query returning 10 rows, some of which are identical except for the last 2 columns which are a comment and a number(…

SQL to find start and end date for an ID

I have a table with ID, start_date and end_date columns. Table: I want to write a query to get the following output: Output: Answer You can do a cumulative sum to solve this variation of the gaps-and-island problem: Demo on DB Fiddle: ID | START_DATE | END_DATE -: | :——— | :——&#8…