Write a query using a window function to find the top three heaviest containers loaded onto each vessel at Mediterranean Shipping.
Use the vessel and container loading tables. Exclude containers whose weight is NULL. Assign distinct, deterministic positions by sorting heavier containers first and breaking equal-weight ties by container ID.
vessel_id, vessel_name, container_id, weight_kg, and weight_rank.vessel_id and weight_rank.| Column | Type | Description |
|---|---|---|
| vessel_idPK | INT | Unique identifier for the vessel |
| vessel_name | VARCHAR(100) | Mediterranean Shipping vessel name |
| registry_port | VARCHAR(100) | Port where the vessel is registered |
| Column | Type | Description |
|---|---|---|
| container_idPK | INT | Unique identifier for the container loading record |
| vessel_id | INT | Vessel carrying the container |
| container_code | VARCHAR(20) | Container identification code |
| weight_kg | NUMERIC(10,2) | Container gross weight in kilograms |