One register for every delivery leg
One register for every delivery leg
You are an analyst at a delivery company. Parcels move around the city with couriers and between cities with trucks, and historically these two flows are written into separate tables. Before the month is closed, finance asks for a single end-to-end register of the legs worked: who carried what parcel and over what distance. For them every row is a separate billable fact, so identical records must not be collapsed: if a courier ran the same leg for the same parcel twice, they get paid twice.
Return columns:
- leg_source — where the record comes from: the text 'courier' for city legs and 'truck' for intercity legs;
- parcel_code — parcel code;
- handler_name — the courier's name for city legs or the driver's name for intercity legs;
- distance_km — leg distance in kilometres, exactly as stored, with no rounding.
Sorting: by parcel_code, then leg_source, then handler_name, then distance_km, all ascending. Do not remove duplicates: fully identical rows must appear in the result as many times as they occur in the source tables.
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.
| leg_source | parcel_code | handler_name | distance_km |
|---|---|---|---|
| courier | PCL-1001 | Ivan Petrov | 3.5 |
| truck | PCL-1001 | Sergey Lomov | 210 |
| courier | PCL-1002 | Olga Sokolova | 7.2 |
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
Entrar