Each row of parts_assembly is one assembly step of one part. Find all parts that have begun assembly but are not finished. A row is unfinished when finish_date is NULL. Output part and assembly_step for every unfinished row.
Input Table(s)
parts_assembly
| Column | Type | Meaning |
|---|
| part | VARCHAR(50), NOT NULL | Name of the part, such as battery or bumper |
| assembly_step | INT, NOT NULL | Step number within that part's assembly |
| finish_date | DATETIME (TIMESTAMP in PostgreSQL), nullable | When the step was finished; NULL while the step is not finished |
Key: each (part, assembly_step) pair appears at most once.
Output Contract
-
Columns, in this order:
part
,
assembly_step
.
-
One row for each row of
parts_assembly
whose
finish_date
is
NULL
.
-
Order by
part
ascending, then
assembly_step
ascending.
-
No rounding or formatting is involved.
Example
Input parts_assembly:
| part | assembly_step | finish_date |
|---|
| battery | 1 | 2022-01-22 00:00:00 |
| battery | 2 | 2022-02-22 00:00:00 |
| battery | 3 | NULL |
| bumper | 1 | 2022-01-22 00:00:00 |
| bumper | 2 | NULL |
Expected output:
| part | assembly_step |
|---|
| battery | 3 |
| bumper | 2 |
Step 3 of battery and step 2 of bumper have no finish date, so they are the only rows returned, and battery sorts before bumper.
Constraints and Clarifications
-
parts_assembly
has at most 10,000 rows.
-
Every row means that step has begun, so the missing
finish_date
is the only condition to test.
-
A part with several unfinished steps appears once for each of them. A part whose steps all have a finish date does not appear.
-
part
and
assembly_step
are never
NULL
, and the (
part
,
assembly_step
) key makes the ordering unique.