Filling a Shipping Container
Problem
A 600-liter shipping container is loaded from `Cargo`, where each row is one parcel of a `cargo_class` (`express` or `standard`) occupying some `volume` (liters). Fill the container to hold as many parcels as possible: first pack whole copies of the entire set of **express** parcels repeatedly until no full set fits, then use whatever volume remains to pack whole copies of the entire set of **standard** parcels. A 'copy' means loading one of every parcel of that class. Report `cargo_class` and `parcel_count` (total parcels loaded) for `express` first, then `standard`.
Tables
Example rows — the live problem includes the full dataset.
| parcel_id | cargo_class | region | volume |
|---|---|---|---|
| 1 | express | North | 60 |
| 2 | express | South | 40 |
| 3 | standard | East | 20 |
Expected output
Your answer should return 2 rows with the columns cargo_class, parcel_count.
Starter code (SQL)
SELECT *
FROM Cargo;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