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 name and distance of the aircrafts with more than 5000 distance and which at least 5 people have its certificate.
assistant
SELECT T2.name FROM Certificate AS T1 JOIN Aircraft AS T2 ON T2.aid = T1.aid WHERE T2.distance > 5000 GROUP BY T1.aid ORDER BY count(*) >= 5
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 minimum, average, and maximum distance of all aircrafts.
assistant
SELECT min(distance) , avg(distance) , max(distance) FROM Aircraft
human
What is the name and distance for aircraft with id 12?
assistant
SELECT name , distance FROM Aircraft WHERE aid = 12
human
How many aircrafts have distance between 1000 and 5000?
assistant
SELECT count(*) FROM Aircraft WHERE distance BETWEEN 1000 AND 5000
human
What are the ids of all aircrafts that can cover a distance of more than 1000?
assistant
SELECT aid FROM Aircraft WHERE distance > 1000 ;