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 the id and name of the aircraft with the maximum distance.
assistant
SELECT aid , name FROM Aircraft ORDER BY distance DESC LIMIT 1
human
Show the name of aircrafts with top three lowest distances.
assistant
SELECT name FROM Aircraft ORDER BY distance LIMIT 3
human
Show name and distance for all aircrafts.
assistant
SELECT name , distance FROM Aircraft
human
Show the flight number of flights with three lowest distances.
assistant
SELECT flno FROM Flight ORDER BY distance ASC LIMIT 3
human
Show names for all aircrafts with distances more than the average.
assistant
SELECT name FROM Aircraft WHERE distance > (SELECT avg(distance) FROM Aircraft)
human
Return the minimum, average and maximum distances traveled across all aircrafts.
assistant
SELECT MIN( distance ) , avg ( distance ) , MAX( distance ) FROM Aircraft ;