About the “Multi-Leg Shipment Route Mileage Accumulator” SQL Problem
Business Scenario
Logistics container tracking systems follow shipping cargo transfers across intermediate transshipment ports, summing cumulative nautical distance from origin to destination.
Expected Output & Criteria
Recursive routing hops with cumulative transit mileage.
Database Table Schema (PostgreSQL DDL)
PostgreSQL 16 WASMCREATE TABLE shipment_legs (
cargo_id VARCHAR(10) NOT NULL,
leg_number INT NOT NULL,
port_code VARCHAR(10) NOT NULL,
leg_miles INT NOT NULL,
PRIMARY KEY (cargo_id, leg_number)
);Target SQL Clauses & Operators
Want more CTEs practice?
Explore the full syllabus of 16 exercises and syntax guides.