Skip to content

Instantly share code, notes, and snippets.

@rruntsch
Created August 26, 2021 16:19
Show Gist options
  • Save rruntsch/e4856e6e01aaac3ed26a8cca03ef9930 to your computer and use it in GitHub Desktop.
Save rruntsch/e4856e6e01aaac3ed26a8cca03ef9930 to your computer and use it in GitHub Desktop.
-- get_us_city_population.sql
-- Clean city names and state codes.
SELECT
CASE
WHEN City = 'Aims' THEN 'Ames'
WHEN City = 'Amerillo' THEN 'Amarillo'
WHEN City = 'Austen' THEN 'Austin'
WHEN City = 'Boyse' THEN 'Boise'
WHEN City = 'Charlestown' THEN 'Charleston'
WHEN City = 'Checago' THEN 'Chicago'
WHEN City = 'DesMoines' THEN 'Des Moines'
WHEN City = 'Honnollullu' THEN 'Honolulu'
WHEN City = 'Rchester' THEN 'Rochester'
WHEN City = 'San Fransisco' THEN 'San Francisco'
ELSE City
END AS City
, CASE
WHEN State_Code = 'MP' AND City = 'Minneapolis' THEN 'MN'
ELSE State_Code
END AS State_Code
, [Population]
FROM City_Population
ORDER BY
State_Code
, City;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment