Duplicate Parcel Registrations
Duplicate Parcel Registrations
You are the data quality analyst for a last-mile delivery platform. Warehouses upload parcel registrations in batches, and retrying a file can create several rows for the same physical parcel. Before carrier compensation is calculated, the billing team needs a duplicate audit so one parcel is not charged more than once.
A registration's business key is the pair carrier_code + tracking_number. Consider only rows where both key components are present: the value is not NULL and is not empty after trimming leading and trailing spaces. Find business keys that occur more than once, count all rows in each duplicate group, and identify the first and last registration times.
Business-key comparison is exact and case-sensitive. Count every row in a matching group, even when all non-key fields are identical.
Return columns:
- carrier_code — carrier code, text;
- tracking_number — tracking number, text;
- duplicate_count — number of rows with this business key, integer;
- first_registered_at — earliest registration time, timestamp with time zone;
- last_registered_at — latest registration time, timestamp with time zone.
Sort by duplicate_count descending, then by carrier_code and tracking_number ascending. No rounding is required. Rows with an incomplete business key must be excluded. Resolve count ties with the stated secondary sort fields.
Exemplo de resposta esperada
É assim que se parece uma resposta correta: ela tem seu próprio número de linhas e não precisa coincidir com as tabelas do esquema. Sua resposta precisa retornar os mesmos nomes de colunas do exemplo: use AS para renomeá-las se for preciso.
| carrier_code | tracking_number | duplicate_count | first_registered_at | last_registered_at |
|---|---|---|---|---|
| FEDEX | FX3002 | 3 | 2026-05-01T11:20:00+00:00 | 2026-05-01T11:45:00+00:00 |
| DHL | TRK1001 | 2 | 2026-05-01T09:00:00+00:00 | 2026-05-01T09:05:00+00:00 |
| UPS | UP2001 | 2 | 2026-05-01T10:10:00+00:00 | 2026-05-01T11:00:00+00:00 |
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
Entrar