AnalystPath

Confirmed or Waitlisted Webinar Seats

SQLHardSenior level~15 min

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.

sessions
session_idseat_limit
12
21
registrations
attendee_idsession_idregistered_at
50112024-05-01 09:00:00
50212024-05-01 09:05:00
50312024-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

Related SQL questions