SQL Tutorial

Selection Techniques

📚 Schema reference · PNW flights 5 tables
airlines
  • carrier
  • name
airports
  • faa
  • name
  • lat
  • lon
  • alt
  • tz
  • dst
  • tzone
flights
  • 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
  • tailnum
  • year
  • type
  • manufacturer
  • model
  • engines
  • seats
  • speed
  • engine
weather
  • origin
  • year
  • month
  • day
  • hour
  • temp
  • dewp
  • humid
  • wind_dir
  • wind_speed
  • wind_gust
  • precip
  • pressure
  • visib
  • time_hour

Selecting columns/fields

  1. Select all airline names from the airlines table.
  1. Select all columns from the weather table.
  1. Select the FAA code and name from the airports table.

Aliasing

  1. Select and alias specific columns from the airports table
  1. Choose the destination airport code and air time from the flights table with an alias f

Unique entries

  1. Select all distinct time zones (tz) from the airports table.

Counting

  1. Count the records in the flights table (aliased as total_flights)
  1. Count all distinct carriers in the flights table as total_distinct_carriers