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 are the IDs of the aircrafts with name Airbus A340-300?
assistant
SELECT distinct aid FROM Aircraft WHERE name = 'Airbus A340-300';
human
What distance does aircraft ID fly? | Do you mean aircraft id 3? And want me to return the sum of all the distances it flew? | Yes please.
assistant
SELECT SUM( distance ) FROM flight WHERE aid = ( SELECT distinct aid FROM Aircraft WHERE name = 'Airbus A340-300' );
human
WHat flight numbers have that aid?
assistant
SELECT T1.flno FROM Flight AS T1 JOIN Aircraft AS T2 ON T1.aid = T2.aid WHERE T2.name = "Airbus A340-300" ;