AnalystPath

Daily Distinct Buyers and Couriers

SQLEasyJunior level~15 min

Problem

Table: `parcel_log`

| Column Name | Type |
|---|---|
| ship_date | date |
| hub_code | varchar |
| buyer_id | int |
| courier_id | int |

This table has no primary key and may contain duplicate rows. Each row records that a parcel was shipped on `ship_date` from warehouse hub `hub_code` for buyer `buyer_id` using courier `courier_id`.

For each combination of `ship_date` and `hub_code`, report the number of **distinct** buyers and the number of **distinct** couriers. Alias the counts `distinct_buyers` and `distinct_couriers`.

Tables

Example rows — the live problem includes the full dataset.

parcel_log
ship_datehub_codebuyer_idcourier_id
2026-01-01north73
2026-01-01north74
2026-01-01north83

Expected output

Your answer should return 3 rows with the columns ship_date, hub_code, distinct_buyers, distinct_couriers.

Starter code (SQL)

SELECT *
FROM parcel_log;

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