human
Schema:
routes (rid, dst_apid, dst_ap, src_apid, src_ap, alid, airline, codeshare)
airports (apid, name, city, country, x, y, elevation, iata, icao)
airlines (alid, name, iata, icao, callsign, country, active)
Please answer with SQL.
assistant
Sure, I understand.
human
Show the name and city of all airports.
assistant
SELECT name , city FROM airports;
human
Show the number of flight routes for each of them as a source airport.
assistant
SELECT T1.name , T1.city , COUNT( * ) FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T2.src_apid;
human
which of them has the most routes?
assistant
SELECT T1.name , T1.city FROM airports AS T1 JOIN routes AS T2 ON T1.apid = T2.src_apid GROUP BY T2.src_apid ORDER BY COUNT( * ) DESC LIMIT 1 ;