Missing Lesson Steps
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_id | step_total |
|---|---|
| 1 | 3 |
| 2 | 2 |
| 3 | 4 |
| lesson_id | step_no |
|---|---|
| 1 | 2 |
| 3 | 1 |
| 3 | 2 |
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