The spaces that break routing
The spaces that break routing
You are a data engineer at a logistics operator. Handheld scanners in the warehouse add random spaces before and after the destination city name, so the sorting hub fails to match the destination against its directory. The operations team needs a report: the cleaned city name and exactly how many whitespace characters had to be removed per shipment — that tells them which scanners misbehave the most.
Return columns:
- shipment_id — shipment id (integer);
- city_clean — city name with leading and trailing spaces removed (do not touch spaces between words);
- chars_removed — how many characters were removed (length of the raw string minus length of the cleaned one, integer).
Exclude shipments where the city is NULL. If a value consisted of spaces only, city_clean becomes an empty string — keep such rows in the report. Sorting: by chars_removed descending, ties by shipment_id ascending.
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.
| shipment_id | city_clean | chars_removed |
|---|---|---|
| 3 | Antwerp | 4 |
| 2 | Hamburg | 3 |
| 7 | Genoa | 3 |
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
Entrar