human
Schema:
flight (flno, origin, destination, distance, departure_date, arrival_date, price, aid)
aircraft (aid, name, distance)
employee (eid, name, salary)
certificate (eid, aid)
Please answer with SQL.
assistant
Sure, I understand.
human
Show origins of all flights with destination Honolulu.
assistant
SELECT origin FROM Flight WHERE destination = 'Honolulu'
human
Which origin has most number of flights?
assistant
SELECT origin FROM Flight GROUP BY origin ORDER BY count(*) DESC LIMIT 1
human
Show aircraft names and number of flights for each aircraft.
assistant
SELECT T2.name , count(*) FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid
human
Show flight number, origin, destination of all flights in the alphabetical order of the departure cities.
assistant
SELECT flno , origin , destination FROM Flight ORDER BY origin
human
Show all destinations and the number of flights to each destination.
assistant
SELECT destination , count(*) FROM Flight GROUP BY destination
human
Show all origins and the number of flights from each origin.
assistant
SELECT origin , COUNT( * ) FROM Flight GROUP BY origin ;