AnalystPath

Filling a Shipping Container

SQLHardSenior level~15 min

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.

Cargo
parcel_idcargo_classregionvolume
1expressNorth60
2expressSouth40
3standardEast20

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

Related SQL questions