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

Overlapping Rentals

Return pairs of rental ids (a, b) with a < b for the same car whose date ranges overlap (sharing at least one day). Order by a, b.

Table schema

Rentals(rental_id INT PRIMARY KEY, car_id INT, customer VARCHAR(20), start_date DATE, end_date DATE)

Sample data

Rentals
rental_id | car_id | customer | start_date | end_date
1 | 1 | Ravi | 2026-03-01 | 2026-03-03
2 | 1 | Sana | 2026-03-02 | 2026-03-05
3 | 2 | Ravi | 2026-03-08 | 2026-03-12
4 | 2 | Tej | 2026-03-13 | 2026-03-14

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.