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 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 the flight number of flights with three lowest distances.
assistant
SELECT flno FROM Flight ORDER BY distance ASC LIMIT 3
human
How many flights do we have?
assistant
SELECT count(*) FROM Flight
human
Which origin has most number of flights?
assistant
SELECT origin FROM Flight GROUP BY origin ORDER BY count(*) DESC LIMIT 1
human
Which destination has least number of flights?
assistant
SELECT destination FROM Flight GROUP BY destination ORDER BY COUNT( * ) LIMIT 1 ;