SQL Tutorial

Exercises — PNW flights

Practice on the Seattle & Portland flights dataset. Write a query, click Run to execute it, then Check answer to compare your result against the expected result. Use Hint for a nudge or Show solution if you're stuck — your progress is saved in your browser.

Tables: airlines, airports, flights, planes, weather.

ER diagram · PNW flights
Text description of this diagram

Five tables centred on flights.

  • airlines — one row per carrier. Columns: carrier (PK), name.
  • airports — one row per airport. Columns: faa (PK), name, lat, lon, alt, tz, dst, tzone.
  • flights — one row per scheduled flight. Columns: year, month, day, dep_time, sched_dep_time, dep_delay, arr_time, sched_arr_time, arr_delay, carrier, flight, tailnum, origin, dest, air_time, distance, hour, minute, time_hour.
  • planes — one row per aircraft. Columns: tailnum (PK), year, type, manufacturer, model, engines, seats, speed, engine.
  • weather — hourly observations per origin airport. Columns: origin, year, month, day, hour, temp, dewp, humid, wind_dir, wind_speed, wind_gust, precip, pressure, visib, time_hour.

Relationships:

  • flights.carrierairlines.carrier
  • flights.originairports.faa
  • flights.destairports.faa
  • flights.tailnumplanes.tailnum
  • weather.originairports.faa