You're a data engineer at a logistics company. Handheld warehouse scanners sometimes add extra spaces to the beginning or end of destination city names. As a result, the sorting center can't match those cities to its routing directory. The operations team needs a report showing the cleaned city name and exactly how many spaces were removed for each shipment. This will help identify which scanners are causing the most problems.
Return these columns:
- shipment_id — shipment ID (integer);
- city_clean — city name with leading and trailing spaces removed (preserve spaces between words);
- chars_removed — number of characters removed (original string length minus cleaned string length, as an integer).
Exclude shipments whose destination city is NULL. If a city name consists entirely of spaces, city_clean will be an empty string; keep those shipments in the report. Sort the result by chars_removed in descending order, breaking ties by shipment_id in ascending order.
shipment_idcity_cleanchars_removedShowing the first 3 rows of the sample — the full sample comes with Premium
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign in