Task 1: Identify the Peak Infection Day in Each City

#1 · 1 of 8Free sample
Question

Task 1: Identify the Peak Infection Day in Each City

Find the date with the highest number of infections for each city. Using the cities and infection_stats tables, join the two tables on city_id and, for each city, select the date at which the new_infections reached its maximum. Return the following columns: city_id, city_name, date, and new_infections.
Tables
4 tables · 17 columns
cities3 cols
  • city_idINTEGER PRIMARY KEY
  • city_nameTEXT NOT NULL
  • populationINTEGER NOT NULL
infection_stats5 cols
  • record_idINTEGER PRIMARY KEY
  • city_idINTEGER NOT NULL
  • dateTEXT NOT NULL
  • new_infectionsINTEGER NOT NULL
  • FOREIGNKEY(city_id) REFERENCES cities(city_id)
vaccine_distribution3 cols
  • city_idINTEGER PRIMARY KEY
  • vaccine_distribution_dateTEXT NOT NULL
  • FOREIGNKEY(city_id) REFERENCES cities(city_id)
survivor_camps6 cols
  • camp_idINTEGER PRIMARY KEY
  • city_idINTEGER NOT NULL
  • camp_nameTEXT NOT NULL
  • capacityINTEGER NOT NULL
  • current_populationINTEGER NOT NULL
  • FOREIGNKEY(city_id) REFERENCES cities(city_id)
Loading the practice editor and dataset…
Your answer(autosaved)
query.sql
Loading editor…
Sign up to unlock

The reference answer is one click away.

Free account unlocks the reference answer, the explanation, and the GPT tutor on every exercise in the library.

  • Reference answer + explanation revealed after each attempt
  • GPT tutor for every problem
  • Progress saved on the platform
  • 1,598 graded exercises
  • Free forever — no credit card
All exercises in Zombie Virus – Part 3: The Cure