SQLSQL
#5

Distinct Location Tracking with DISTINCT vs GROUP BY in SQL

Easy
Interview Question #5

From a `shipments` table, find all unique combinations of `origin_hub` and `destination_city` where shipment status is 'Completed'.

Input Table: shipments
4 rows preview
shipment_idorigin_hubdestination_citystatus
S1Delhi HubJaipurCompleted
S2Delhi HubJaipurCompleted
S3Mumbai HubPuneCompleted
S4Delhi HubAgraIn Transit
Expected Output Structure2 rows
origin_hubdestination_city
Delhi HubJaipur
Mumbai HubPune
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

SQLPostgreSQL 15
Ready to execute

Click "Run Query" or press Ctrl + Enter to test your query.

Output will be verified against the test dataset.

Chat with us