Category "gaps-and-islands"

calculate each in and out duration for an id

I've data like below Id date time type 1 01-01-2022 08:00 in 1 01-01-2022 11:30 out 1 01-01-2022 11:35 out 1 01-01-2022 12:45 in 1 01-01-2022 17:30 out 1 01-01

Group up date ranges by interesecting ranges

This is a variation of the gaps and islands problem. I tried finding solutions but they are all SQL based. Problem: Given a list of date ranges, return a combin

Detect SQL island over multiple parameters and conditions

(PostgreSQL 8.4) I got a great introduction to SQL gaps-and-islands here on Stack Overflow but I still have a question. Many island detection CTEs are based on