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 of all aircrafts.
assistant
SELECT name FROM Aircraft;
human
Also show the number of people with a certificate on each one.
assistant
SELECT T2.name , COUNT( * ) FROM Certificate AS T1 JOIN Aircraft AS T2 ON T2.aid = T1.aid GROUP BY T1.aid;
human
Order the aircraft by these counts.
assistant
SELECT T2.name FROM Certificate AS T1 JOIN Aircraft AS T2 ON T2.aid = T1.aid GROUP BY T1.aid ORDER BY COUNT( * ) ;