Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Overlapping Bookings

Two bookings of the same room overlap when one starts before the other ends (a check-out day equals the next check-in day is NOT an overlap). Return the id pairs (a_id < b_id) that overlap, ordered by pair.

Table schema

Bookings(id INT PRIMARY KEY, room INT, guest VARCHAR(10), check_in DATE, check_out DATE)

Sample data

id | room | guest | check_in | check_out
1 | 101 | Ann | 2026-07-01 | 2026-07-05
2 | 101 | Bob | 2026-07-04 | 2026-07-08
3 | 102 | Cy | 2026-07-02 | 2026-07-04
4 | 101 | Dee | 2026-07-08 | 2026-07-10
5 | 103 | Eli | 2026-07-06 | 2026-07-10

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.