Interview practice question
Overlapping bookings
Data Engineering · SQL · Intermediate
In a room bookings table with start and end times, find bookings that overlap for the same room.
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Two ranges overlap if a.start < b.end and b.start < a.end.
- Self join on room with that condition.
- Use a.id < b.id to avoid duplicate pairs and self matches.
- Decide whether touching endpoints count as overlap.
- Alternative: LAG on sorted bookings per room.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.