Katkat

Write SQL to sum city population by name

NVIDIASoftware Engineer · Technical Screen

Last updated

Assesses SQL proficiency in relational joins and aggregation by asking for a total population computed from ZIP-level data and evaluates reasoning about duplicate entity names.

You have four relational tables:

  • country(country_id, name)
  • state(state_id, country_id, name)
  • city(city_id, state_id, name)
  • zip(zip_code, city_id, population)

Task A: Given a city name (e.g., :city_name), write SQL to return the total population for that city, where population is stored in the zip table (sum across all ZIP codes belonging to the city).

Clarify how you would handle the case where multiple cities share the same name in different states/countries.