A bug in a calendar sync let some listings be booked twice for the same nights. Airbnb's trust team needs to know which bookings clash and how much money is at stake. Check-out day and the next guest's check-in day can be the same without clashing.
List every pair of confirmed bookings for the same listing whose stays overlap, with the number of nights they share. Show each pair once, smaller booking_id first.
Expected output
Example of the shape (made-up values):
| listing_id | booking_a | booking_b | overlap_nights |
|---|---|---|---|
| 140 | 822 | 1675 | 2 |
Hints, the later steps and the answer come with Pro.
Step 1 of 2
Write your query here. Ctrl + Enter submits.