Heaviest Parcel Shipped Each Day
Problem
Table: `Shipments`
```text
+-------------+----------+
| Column Name | Type |
+-------------+----------+
| parcel_id | int |
| ship_ts | datetime |
| weight_kg | int |
+-------------+----------+
parcel_id is the primary key for this table.
Each row describes one parcel: when it left the depot and how much it weighed.
```
A logistics depot wants to flag the heaviest parcel it sent out on each calendar day. If two or more parcels on the same day tie for the highest weight, all of them should be flagged.
Write a solution to report the `parcel_id` of the heaviest parcel(s) shipped on each day.
Return the result table ordered by `parcel_id` in ascending order.
Tables
Example rows — the live problem includes the full dataset.
| parcel_id | ship_ts | weight_kg |
|---|---|---|
| 1 | 2023-09-01 08:15:00 | 12 |
| 2 | 2023-09-01 16:40:00 | 30 |
| 3 | 2023-09-01 11:00:00 | 30 |
Expected output
Your answer should return 4 rows with the columns parcel_id.
Starter code (SQL)
SELECT *
FROM Shipments;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