Confirmed or Waitlisted Webinar Seats
Problem
Tables: `sessions`, `registrations`
**sessions**
| Column Name | Type |
|---|---|
| session_id | int |
| seat_limit | int |
`session_id` is the primary key. `seat_limit` is how many confirmed seats the webinar offers.
**registrations**
| Column Name | Type |
|---|---|
| attendee_id | int |
| session_id | int |
| registered_at | datetime |
`attendee_id` is the primary key. Each row is one person registering for one session at a specific time; registration times within a session are distinct.
Seats are filled first-come-first-served by `registered_at`. The earliest `seat_limit` registrations of a session are `Confirmed`; everyone after that is `Waitlist`. Return each `attendee_id` and their `seat_status`, ordered by `attendee_id`.
Tables
Example rows — the live problem includes the full dataset.
| session_id | seat_limit |
|---|---|
| 1 | 2 |
| 2 | 1 |
| attendee_id | session_id | registered_at |
|---|---|---|
| 501 | 1 | 2024-05-01 09:00:00 |
| 502 | 1 | 2024-05-01 09:05:00 |
| 503 | 1 | 2024-05-01 09:10:00 |
Expected output
Your answer should return 5 rows with the columns attendee_id, seat_status.
Starter code (SQL)
SELECT *
FROM sessions;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock