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
What is the name and distance for aircraft with id 12?
assistant
SELECT name , distance FROM Aircraft WHERE aid = 12
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
Show names for all aircraft with at least two flights.
assistant
SELECT T2.name FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid GROUP BY T1.aid HAVING count(*) >= 2
human
Show name and distance for all aircrafts.
assistant
SELECT name , distance FROM Aircraft
human
What are the aircrafts with top 3 shortest lengthes? List their names.
assistant
SELECT name FROM Aircraft ORDER BY distance LIMIT 3 ;