Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Find the faculty rank that has the least members. [/INST]

Output: SELECT rank FROM Faculty GROUP BY rank ORDER BY count(*) ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show the number of male and female assistant professors. [/INST]

Output: SELECT sex ,  count(*) FROM Faculty WHERE rank  =  "AsstProf" GROUP BY sex;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: How many male and female assistant professors do we have? [/INST]

Output: SELECT sex ,  count(*) FROM Faculty WHERE rank  =  "AsstProf" GROUP BY sex;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What are the first name and last name of Linda Smith's advisor? [/INST]

Output: SELECT T1.fname ,  T1.lname FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor WHERE T2.fname  =  "Linda" AND T2.lname  =  "Smith";


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Who is the advisor of Linda Smith? Give me the first name and last name. [/INST]

Output: SELECT T1.fname ,  T1.lname FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor WHERE T2.fname  =  "Linda" AND T2.lname  =  "Smith";


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show the ids of students whose advisors are professors. [/INST]

Output: SELECT T2.StuID FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor WHERE T1.rank  =  "Professor";


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Which students have professors as their advisors? Find their student ids. [/INST]

Output: SELECT T2.StuID FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor WHERE T1.rank  =  "Professor";


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show first name and last name for all the students advised by Michael Goodrich. [/INST]

Output: SELECT T2.fname ,  T2.lname FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor WHERE T1.fname  =  "Michael" AND T1.lname  =  "Goodrich";


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Which students are advised by Michael Goodrich? Give me their first and last names. [/INST]

Output: SELECT T2.fname ,  T2.lname FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor WHERE T1.fname  =  "Michael" AND T1.lname  =  "Goodrich";


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show the faculty id of each faculty member, along with the number of students he or she advises. [/INST]

Output: SELECT T1.FacID ,  count(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor GROUP BY T1.FacID;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What are the faculty id and the number of students each faculty has? [/INST]

Output: SELECT T1.FacID ,  count(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor GROUP BY T1.FacID;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show all the faculty ranks and the number of students advised by each rank. [/INST]

Output: SELECT T1.rank ,  count(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor GROUP BY T1.rank;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: How many students are advised by each rank of faculty? List the rank and the number of students. [/INST]

Output: SELECT T1.rank ,  count(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor GROUP BY T1.rank;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What are the first and last name of the faculty who has the most students? [/INST]

Output: SELECT T1.fname ,  T1.lname FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor GROUP BY T1.FacID ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Give me the the first and last name of the faculty who advises the most students. [/INST]

Output: SELECT T1.fname ,  T1.lname FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor GROUP BY T1.FacID ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show the ids for all the faculty members who have at least 2 students. [/INST]

Output: SELECT T1.FacID FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor GROUP BY T1.FacID HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Which faculty members advise two ore more students? Give me their faculty ids. [/INST]

Output: SELECT T1.FacID FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID  =  T2.advisor GROUP BY T1.FacID HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show ids for the faculty members who don't advise any student. [/INST]

Output: SELECT FacID FROM Faculty EXCEPT SELECT advisor FROM Student;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What are the ids of the faculty members who do not advise any student. [/INST]

Output: SELECT FacID FROM Faculty EXCEPT SELECT advisor FROM Student;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What activities do we have? [/INST]

Output: SELECT activity_name FROM Activity;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: List all the activities we have. [/INST]

Output: SELECT activity_name FROM Activity;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: How many activities do we have? [/INST]

Output: SELECT count(*) FROM Activity;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Find the number of activities available. [/INST]

Output: SELECT count(*) FROM Activity;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: How many faculty members participate in an activity? [/INST]

Output: SELECT count(DISTINCT FacID) FROM Faculty_participates_in;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Give me the number of faculty members who participate in an activity [/INST]

Output: SELECT count(DISTINCT FacID) FROM Faculty_participates_in;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show the ids of the faculty who don't participate in any activity. [/INST]

Output: SELECT FacID FROM Faculty EXCEPT SELECT FacID FROM Faculty_participates_in;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Which faculty do not participate in any activity? Find their faculty ids. [/INST]

Output: SELECT FacID FROM Faculty EXCEPT SELECT FacID FROM Faculty_participates_in;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show the ids of all the faculty members who participate in an activity and advise a student. [/INST]

Output: SELECT FacID FROM Faculty_participates_in INTERSECT SELECT advisor FROM Student;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What are ids of the faculty members who not only participate in an activity but also advise a student. [/INST]

Output: SELECT FacID FROM Faculty_participates_in INTERSECT SELECT advisor FROM Student;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: How many activities does Mark Giuliano participate in? [/INST]

Output: SELECT count(*) FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID WHERE T1.fname  =  "Mark" AND T1.lname  =  "Giuliano";


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Find the number of activities Mark Giuliano is involved in. [/INST]

Output: SELECT count(*) FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID WHERE T1.fname  =  "Mark" AND T1.lname  =  "Giuliano";


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show the names of all the activities Mark Giuliano participates in. [/INST]

Output: SELECT T3.activity_name FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID JOIN Activity AS T3 ON T3.actid  =  T2.actid WHERE T1.fname  =  "Mark" AND T1.lname  =  "Giuliano";


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of the activities Mark Giuliano is involved in [/INST]

Output: SELECT T3.activity_name FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID JOIN Activity AS T3 ON T3.actid  =  T2.actid WHERE T1.fname  =  "Mark" AND T1.lname  =  "Giuliano";


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show the first and last name of all the faculty members who participated in some activity, together with the number of activities they participated in. [/INST]

Output: SELECT  T1.fname ,  T1.lname ,  count(*) ,  T1.FacID FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID GROUP BY T1.FacID;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What is the first and last name of the faculty members who participated in at least one activity? For each of them, also show the number of activities they participated in. [/INST]

Output: SELECT  T1.fname ,  T1.lname ,  count(*) ,  T1.FacID FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID GROUP BY T1.FacID;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show all the activity names and the number of faculty involved in each activity. [/INST]

Output: SELECT T1.activity_name ,  count(*) FROM Activity AS T1 JOIN Faculty_participates_in AS T2 ON T1.actID  =  T2.actID GROUP BY T1.actID;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: How many faculty members participate in each activity? Return the activity names and the number of faculty members. [/INST]

Output: SELECT T1.activity_name ,  count(*) FROM Activity AS T1 JOIN Faculty_participates_in AS T2 ON T1.actID  =  T2.actID GROUP BY T1.actID;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What is the first and last name of the faculty participating in the most activities? [/INST]

Output: SELECT  T1.fname ,  T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID GROUP BY T1.FacID ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Find the first and last name of the faculty who is involved in the largest number of activities. [/INST]

Output: SELECT  T1.fname ,  T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID GROUP BY T1.FacID ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name of the activity that has the most faculty members involved in? [/INST]

Output: SELECT T1.activity_name FROM Activity AS T1 JOIN Faculty_participates_in AS T2 ON T1.actID  =  T2.actID GROUP BY T1.actID ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Which activity has the most faculty members participating in? Find the activity name. [/INST]

Output: SELECT T1.activity_name FROM Activity AS T1 JOIN Faculty_participates_in AS T2 ON T1.actID  =  T2.actID GROUP BY T1.actID ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show the ids of the students who don't participate in any activity. [/INST]

Output: SELECT StuID FROM Student EXCEPT SELECT StuID FROM Participates_in;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What are the ids of the students who are not involved in any activity [/INST]

Output: SELECT StuID FROM Student EXCEPT SELECT StuID FROM Participates_in;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Show the ids for all the students who participate in an activity and are under 20. [/INST]

Output: SELECT StuID FROM Participates_in INTERSECT SELECT StuID FROM Student WHERE age  <  20;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What are the ids of the students who are under 20 years old and are involved in at least one activity. [/INST]

Output: SELECT StuID FROM Participates_in INTERSECT SELECT StuID FROM Student WHERE age  <  20;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What is the first and last name of the student participating in the most activities? [/INST]

Output: SELECT T1.fname ,  T1.lname FROM Student AS T1 JOIN Participates_in AS T2 ON T1.StuID  =  T2.StuID GROUP BY T1.StuID ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Tell me the first and last name of the student who has the most activities. [/INST]

Output: SELECT T1.fname ,  T1.lname FROM Student AS T1 JOIN Participates_in AS T2 ON T1.StuID  =  T2.StuID GROUP BY T1.StuID ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name of the activity with the most students? [/INST]

Output: SELECT T1.activity_name FROM Activity AS T1 JOIN Participates_in AS T2 ON T1.actID  =  T2.actID GROUP BY T1.actID ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name of the activity that has the largest number of student participants. [/INST]

Output: SELECT T1.activity_name FROM Activity AS T1 JOIN Participates_in AS T2 ON T1.actID  =  T2.actID GROUP BY T1.actID ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Find the first names of the faculty members who are playing Canoeing or Kayaking. [/INST]

Output: SELECT DISTINCT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID JOIN activity AS T3 ON T2.actid  =  T2.actid WHERE T3.activity_name  =  'Canoeing' OR T3.activity_name  =  'Kayaking';


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Which faculty members are playing either Canoeing or Kayaking? Tell me their first names. [/INST]

Output: SELECT DISTINCT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID JOIN activity AS T3 ON T2.actid  =  T2.actid WHERE T3.activity_name  =  'Canoeing' OR T3.activity_name  =  'Kayaking';


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Find the first names of professors who are not playing Canoeing or Kayaking. [/INST]

Output: SELECT lname FROM faculty WHERE rank  =  'Professor' EXCEPT SELECT DISTINCT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID JOIN activity AS T3 ON T2.actid  =  T2.actid WHERE T3.activity_name  =  'Canoeing' OR T3.activity_name  =  'Kayaking';


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What are the first names of the professors who do not play Canoeing or Kayaking as activities? [/INST]

Output: SELECT lname FROM faculty WHERE rank  =  'Professor' EXCEPT SELECT DISTINCT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID JOIN activity AS T3 ON T2.actid  =  T2.actid WHERE T3.activity_name  =  'Canoeing' OR T3.activity_name  =  'Kayaking';


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Find the first names of the faculty members who participate in Canoeing and Kayaking. [/INST]

Output: SELECT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID JOIN activity AS T3 ON T2.actid  =  T2.actid WHERE T3.activity_name  =  'Canoeing' INTERSECT SELECT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID JOIN activity AS T3 ON T2.actid  =  T2.actid WHERE T3.activity_name  =  'Kayaking';


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: What are the first names of the faculty members playing both Canoeing and Kayaking? [/INST]

Output: SELECT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID JOIN activity AS T3 ON T2.actid  =  T2.actid WHERE T3.activity_name  =  'Canoeing' INTERSECT SELECT T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID  =  T2.facID JOIN activity AS T3 ON T2.actid  =  T2.actid WHERE T3.activity_name  =  'Kayaking';


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Find the ids of the students who participate in Canoeing and Kayaking. [/INST]

Output: SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid  =  T2.actid WHERE T2.activity_name  =  'Canoeing' INTERSECT SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid  =  T2.actid WHERE T2.activity_name  =  'Kayaking';


Input:
[INST] Here is a database schema:
Activity :
actid [ INT ] primary_key
activity_name [ TEXT ]

Participates_in :
stuid [ INT ] Participates_in.stuid = Student.StuID
actid [ INT ] Participates_in.actid = Activity.actid

Faculty_Participates_in :
FacID [ INT ] Faculty_Participates_in.FacID = Faculty.FacID
actid [ INT ] Faculty_Participates_in.actid = Activity.actid

Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Faculty :
FacID [ INT ] primary_key
Lname [ TEXT ]
Fname [ TEXT ]
Rank [ TEXT ]
Sex [ TEXT ]
Phone [ INT ]
Room [ TEXT ]
Building [ TEXT ]

Please write me a SQL statement that answers the following question: Which students participate in both Canoeing and Kayaking as their activities? Tell me their student ids. [/INST]

Output: SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid  =  T2.actid WHERE T2.activity_name  =  'Canoeing' INTERSECT SELECT T1.stuid FROM participates_in AS T1 JOIN activity AS T2 ON T2.actid  =  T2.actid WHERE T2.activity_name  =  'Kayaking';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name of the airport in the city of Goroka. [/INST]

Output: SELECT name FROM airports WHERE city  =  'Goroka';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of the airports in the city of Goroka? [/INST]

Output: SELECT name FROM airports WHERE city  =  'Goroka';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name, city, country, and altitude (or elevation) of the airports in the city of New York. [/INST]

Output: SELECT name ,  city ,  country ,  elevation FROM airports WHERE city  =  'New York';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name, city, country, and elevation for every airport in the city of New York? [/INST]

Output: SELECT name ,  city ,  country ,  elevation FROM airports WHERE city  =  'New York';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: How many airlines are there? [/INST]

Output: SELECT count(*) FROM airlines;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the total number of airlines? [/INST]

Output: SELECT count(*) FROM airlines;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: How many airlines does Russia has? [/INST]

Output: SELECT count(*) FROM airlines WHERE country  =  'Russia';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the number of airlines based in Russia? [/INST]

Output: SELECT count(*) FROM airlines WHERE country  =  'Russia';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the maximum elevation of all airports in the country of Iceland? [/INST]

Output: SELECT max(elevation) FROM airports WHERE country  =  'Iceland';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the highest elevation of an airport in the country of Iceland? [/INST]

Output: SELECT max(elevation) FROM airports WHERE country  =  'Iceland';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name of the airports located in Cuba or Argentina. [/INST]

Output: SELECT name FROM airports WHERE country  =  'Cuba' OR country  =  'Argentina';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of all airports in Cuba or Argentina? [/INST]

Output: SELECT name FROM airports WHERE country  =  'Cuba' OR country  =  'Argentina';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the country of the airlines whose name starts with 'Orbit'. [/INST]

Output: SELECT country FROM airlines WHERE name LIKE 'Orbit%';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What are the countries of all airlines whose names start with Orbit? [/INST]

Output: SELECT country FROM airlines WHERE name LIKE 'Orbit%';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name of airports whose altitude is between -50 and 50. [/INST]

Output: SELECT name FROM airports WHERE elevation BETWEEN -50 AND 50;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of all airports whose elevation is between -50 and 50? [/INST]

Output: SELECT name FROM airports WHERE elevation BETWEEN -50 AND 50;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Which country is the airport that has the highest altitude located in? [/INST]

Output: SELECT country FROM airports ORDER BY elevation DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the country of the airport with the highest elevation? [/INST]

Output: SELECT country FROM airports ORDER BY elevation DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the number of airports whose name contain the word 'International'. [/INST]

Output: SELECT count(*) FROM airports WHERE name LIKE '%International%';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: How many airports' names have the word Interanation in them? [/INST]

Output: SELECT count(*) FROM airports WHERE name LIKE '%International%';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: How many different cities do have some airport in the country of Greenland? [/INST]

Output: SELECT count(DISTINCT city) FROM airports WHERE country  =  'Greenland';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: In how many cities are there airports in the country of Greenland? [/INST]

Output: SELECT count(DISTINCT city) FROM airports WHERE country  =  'Greenland';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the number of routes operated by American Airlines. [/INST]

Output: SELECT count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid  =  T2.alid WHERE T1.name  =  'American Airlines';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: How many routes does American Airlines operate? [/INST]

Output: SELECT count(*) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid  =  T2.alid WHERE T1.name  =  'American Airlines';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the number of routes whose destination airports are in Canada. [/INST]

Output: SELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.dst_apid WHERE country  =  'Canada';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: How many routes end in a Canadian airport? [/INST]

Output: SELECT count(*) FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.dst_apid WHERE country  =  'Canada';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name, city, and country of the airport that has the lowest altitude. [/INST]

Output: SELECT name ,  city ,  country FROM airports ORDER BY elevation LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name, city, and country of the airport with the lowest altitude? [/INST]

Output: SELECT name ,  city ,  country FROM airports ORDER BY elevation LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name, city, and country of the airport that has the highest latitude. [/INST]

Output: SELECT name ,  city ,  country FROM airports ORDER BY elevation DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name, city, and country of the airport with the highest elevation? [/INST]

Output: SELECT name ,  city ,  country FROM airports ORDER BY elevation DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name and city of the airport which is the destination of the most number of routes. [/INST]

Output: SELECT T1.name ,  T1.city ,  T2.dst_apid FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.dst_apid GROUP BY T2.dst_apid ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name and city of the airport that the most routes end at? [/INST]

Output: SELECT T1.name ,  T1.city ,  T2.dst_apid FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.dst_apid GROUP BY T2.dst_apid ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the names of the top 10 airlines that operate the most number of routes. [/INST]

Output: SELECT T1.name ,  T2.alid FROM airlines AS T1 JOIN routes AS T2 ON T1.alid  =  T2.alid GROUP BY T2.alid ORDER BY count(*) DESC LIMIT 10;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: For the airline ids with the top 10 most routes operated, what are their names? [/INST]

Output: SELECT T1.name ,  T2.alid FROM airlines AS T1 JOIN routes AS T2 ON T1.alid  =  T2.alid GROUP BY T2.alid ORDER BY count(*) DESC LIMIT 10;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the name and city of the airport which is the source for the most number of flight routes. [/INST]

Output: SELECT T1.name ,  T1.city ,  T2.src_apid FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.src_apid GROUP BY T2.src_apid ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name and city of the airport from most of the routes start? [/INST]

Output: SELECT T1.name ,  T1.city ,  T2.src_apid FROM airports AS T1 JOIN routes AS T2 ON T1.apid  =  T2.src_apid GROUP BY T2.src_apid ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Find the number of different airports which are the destinations of the American Airlines. [/INST]

Output: SELECT count(DISTINCT dst_apid) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid  =  T2.alid WHERE T1.name  =  'American Airlines';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the number of different different airports that are destinations for American Airlines? [/INST]

Output: SELECT count(DISTINCT dst_apid) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid  =  T2.alid WHERE T1.name  =  'American Airlines';


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Which countries has the most number of airlines? [/INST]

Output: SELECT country FROM airlines GROUP BY country ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name of the country with the most number of home airlines? [/INST]

Output: SELECT country FROM airlines GROUP BY country ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Which countries has the most number of airlines whose active status is 'Y'? [/INST]

Output: SELECT country FROM airlines WHERE active  =  'Y' GROUP BY country ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What are the countries with the most airlines whose active status is Y? [/INST]

Output: SELECT country FROM airlines WHERE active  =  'Y' GROUP BY country ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: List all countries and their number of airlines in the descending order of number of airlines. [/INST]

Output: SELECT country ,  count(*) FROM airlines GROUP BY country ORDER BY count(*) DESC;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: How many airlines operate out of each country in descending order? [/INST]

Output: SELECT country ,  count(*) FROM airlines GROUP BY country ORDER BY count(*) DESC;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: How many airports are there per country? Order the countries by decreasing number of airports. [/INST]

Output: SELECT count(*) ,  country FROM airports GROUP BY country ORDER BY count(*) DESC;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the number of airports per country, ordered from most to least? [/INST]

Output: SELECT count(*) ,  country FROM airports GROUP BY country ORDER BY count(*) DESC;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: How many airports are there per city in the United States? Order the cities by decreasing number of airports. [/INST]

Output: SELECT count(*) ,  city FROM airports WHERE country  =  'United States' GROUP BY city ORDER BY count(*) DESC;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: How many airports are there per city in the US ordered from most to least? [/INST]

Output: SELECT count(*) ,  city FROM airports WHERE country  =  'United States' GROUP BY city ORDER BY count(*) DESC;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: Return the cities with more than 3 airports in the United States. [/INST]

Output: SELECT city FROM airports WHERE country  =  'United States' GROUP BY city HAVING count(*)  >  3;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the number of cities in the United States with more than 3 airports? [/INST]

Output: SELECT city FROM airports WHERE country  =  'United States' GROUP BY city HAVING count(*)  >  3;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: How many cities are there that have more than 3 airports? [/INST]

Output: SELECT count(*) FROM (SELECT city FROM airports GROUP BY city HAVING count(*)  >  3);


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What is the count of cities with more than 3 airports? [/INST]

Output: SELECT count(*) FROM (SELECT city FROM airports GROUP BY city HAVING count(*)  >  3);


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: List the cities which have more than one airport and number of airports. [/INST]

Output: SELECT city ,  count(*) FROM airports GROUP BY city HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What are the names of all cities with more than one airport and how many airports do they have? [/INST]

Output: SELECT city ,  count(*) FROM airports GROUP BY city HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: List the cities which have more than 2 airports sorted by the number of airports. [/INST]

Output: SELECT city FROM airports GROUP BY city HAVING count(*)  >  2 ORDER BY count(*);


Input:
[INST] Here is a database schema:
routes :
rid [ INT ] primary_key
dst_apid [ INT ] routes.dst_apid = airports.apid
dst_ap [ TEXT ]
src_apid [ INT ] routes.src_apid = airports.apid
src_ap [ TEXT ]
alid [ INT ] routes.alid = airlines.alid
airline [ TEXT ]
codeshare [ TEXT ]

airports :
apid [ INT ] primary_key
name [ TEXT ]
city [ TEXT ]
country [ TEXT ]
x [ INT ]
y [ INT ]
elevation [ INT ]
iata [ TEXT ]
icao [ TEXT ]

airlines :
alid [ INT ] primary_key
name [ TEXT ]
iata [ TEXT ]
icao [ TEXT ]
callsign [ TEXT ]
country [ TEXT ]
active [ TEXT ]

Please write me a SQL statement that answers the following question: What are the cities that have more than 2 airports sorted by number of airports? [/INST]

Output: SELECT city FROM airports GROUP BY city HAVING count(*)  >  2 ORDER BY count(*);