For example, find the flights that departed each year, by IATA code,
airport, city, state, and country. Find the average departure
delay.
SELECT f.month, a.iata, a.airport, a.city, a.state, a.country
FROM flights f,
airports a
WHERE f.origin = a.iata
GROUP BY
f.month,
a.iata,
a.airport,
a.city,
a.state,
a.country
HAVING COUNT(*) > 10000
ORDER BY AVG(f.DepDelay) DESC
LIMIT 10;
Output
appears as
follows:
+----------+---------+------------------------------------+---------------+----------+------------+
| f.month | a.iata | a.airport | a.city | a.state | a.country |
+----------+---------+------------------------------------+---------------+----------+------------+
| 12 | ORD | Chicago O'Hare International | Chicago | NULL | USA |
| 6 | EWR | Newark Intl | Newark | NULL | USA |
| 7 | JFK | John F Kennedy Intl | New York | NULL | USA |
| 6 | IAD | Washington Dulles International | Chantilly | NULL | USA |
| 7 | EWR | Newark Intl | Newark | NULL | USA |
| 6 | PHL | Philadelphia Intl | Philadelphia | NULL | USA |
| 1 | ORD | Chicago O'Hare International | Chicago | NULL | USA |
| 6 | ORD | Chicago O'Hare International | Chicago | NULL | USA |
| 7 | ATL | William B Hartsfield-Atlanta Intl | Atlanta | NULL | USA |
| 12 | MDW | Chicago Midway | Chicago | NULL | USA |
+----------+---------+------------------------------------+---------------+----------+------------+
10 rows selected (103.812 seconds)