AnalystPath

Class Reservations and Waitlist Counts

SQLMediumMid level~15 min

Problem

Tables: `classes`, `signups`

**classes**
| Column Name | Type |
|---|---|
| class_id | int |
| max_spots | int |

`class_id` is the primary key. `max_spots` is how many members the studio room physically holds.

**signups**
| Column Name | Type |
|---|---|
| member_id | int |
| class_id | int |

Each row is one member signing up for one class. Sign-ups beyond `max_spots` go onto a waitlist.

For every class, report `class_id`, `reserved_cnt` (members who got a confirmed spot, capped at `max_spots`), and `waitlist_cnt` (members who overflowed onto the waitlist, or 0 if none). Include classes with no sign-ups. Order by `class_id`.

Tables

Example rows — the live problem includes the full dataset.

classes
class_idmax_spots
12
25
31
signups
member_idclass_id
101
111
121

Expected output

Your answer should return 3 rows with the columns class_id, reserved_cnt, waitlist_cnt.

Starter code (SQL)

SELECT *
FROM classes;

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