How iteratively reduce the number of rows in a group according to a given condition PostgreSQL
I have the table like: start_dt end_dt ID Index 2023-01-01 2023-03-08 A i 2023-05-08 2023-06-18 A i+1 2023-12-09 2024-02-02 A i+2 2024-12-01 2025-01-05 A i+3 2023-02-01 2023-03-07 B j 2023-06-08 2023-07-18 B j+1 2024-12-09 2024-02-02 B j+2 I need to…