AnalystPath

Missing Lesson Steps

SQLHardSenior level~15 min

Problem

An online course platform breaks each lesson into a fixed number of sequentially-numbered steps.

```
Lesson
+-------------+------+
| Column | Type |
+-------------+------+
| lesson_id | int |
| step_total | int |
+-------------+------+
lesson_id is the primary key. A lesson with step_total = n has steps numbered 1..n.

CompletedStep
+-------------+------+
| Column | Type |
+-------------+------+
| lesson_id | int |
| step_no | int |
+-------------+------+
(lesson_id, step_no) is the primary key. Each row means a learner finished that step.
```

For every lesson, report the steps that were **never** completed.

Return `lesson_id` and `step_no` in any order.

Tables

Example rows — the live problem includes the full dataset.

Lesson
lesson_idstep_total
13
22
34
CompletedStep
lesson_idstep_no
12
31
32

Expected output

Your answer should return 4 rows with the columns lesson_id, step_no.

Starter code (SQL)

SELECT *
FROM Lesson;

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