-- It combines with UNNEST -- to implement the temporal database "coalesce" function -- (see Snodgrass 6.5.2): SELECT room_id, t2.booked_during FROM ( SELECT room_id, range_agg(booked_during, true, true) AS booked_during FROM reservations GROUP BY room_id ) AS t1, UNNEST(t1.booked_during) AS t2(booked_during) ORDER BY room_id, booked_during ; room_id | booked_during ---------+------------------------- 1 | [07-01-2018,07-14-2018) 1 | [07-20-2018,07-22-2018) 2 | [07-01-2018,07-03-2018) 5 | [07-01-2018,07-03-2018) 6 | [07-01-2018,07-10-2018) 7 | [07-01-2018,07-14-2018) (6 rows)