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
What is the minimum, average, and maximum distance of all aircrafts.
assistant
SELECT min(distance) , avg(distance) , max(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
How many aircrafts have distance between 1000 and 5000?
assistant
SELECT count(*) FROM Aircraft WHERE distance BETWEEN 1000 AND 5000
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 the name of aircrafts with top three lowest distances.
assistant
SELECT name FROM Aircraft ORDER BY distance LIMIT 3
human
What are the names and distances for all airplanes?
assistant
SELECT name , distance FROM Aircraft ;