Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many students exist? [/INST]

Output: SELECT count(*) FROM student;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the average age of all students living in the each city. [/INST]

Output: SELECT avg(age) ,  city_code FROM student GROUP BY city_code;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the average age for each city and what are those cities? [/INST]

Output: SELECT avg(age) ,  city_code FROM student GROUP BY city_code;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the average and total capacity of dorms for the students with gender X. [/INST]

Output: SELECT avg(student_capacity) ,  sum(student_capacity) FROM dorm WHERE gender  =  'X';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the average and total capacity for all dorms who are of gender X? [/INST]

Output: SELECT avg(student_capacity) ,  sum(student_capacity) FROM dorm WHERE gender  =  'X';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the number of dorms that have some amenity. [/INST]

Output: SELECT count(DISTINCT dormid) FROM has_amenity;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

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

Output: SELECT count(DISTINCT dormid) FROM has_amenity;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the name of dorms that do not have any amenity [/INST]

Output: SELECT dorm_name FROM dorm WHERE dormid NOT IN (SELECT dormid FROM has_amenity);


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the names of all the dorms that don't have any amenities? [/INST]

Output: SELECT dorm_name FROM dorm WHERE dormid NOT IN (SELECT dormid FROM has_amenity);


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the number of distinct gender for dorms. [/INST]

Output: SELECT count(DISTINCT gender) FROM dorm;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

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

Output: SELECT count(DISTINCT gender) FROM dorm;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the capacity and gender type of the dorm whose name has substring ‘Donor’. [/INST]

Output: SELECT student_capacity ,  gender FROM dorm WHERE dorm_name LIKE '%Donor%';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the student capacity and type of gender for the dorm whose name as the phrase Donor in it? [/INST]

Output: SELECT student_capacity ,  gender FROM dorm WHERE dorm_name LIKE '%Donor%';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the name and gender type of the dorms whose capacity is greater than 300 or less than 100. [/INST]

Output: SELECT dorm_name ,  gender FROM dorm WHERE student_capacity  >  300 OR student_capacity  <  100;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the names and types of the dorms that have a capacity greater than 300 or less than 100? [/INST]

Output: SELECT dorm_name ,  gender FROM dorm WHERE student_capacity  >  300 OR student_capacity  <  100;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the numbers of different majors and cities. [/INST]

Output: SELECT count(DISTINCT major) ,  count(DISTINCT city_code) FROM student;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many different majors are there and how many different city codes are there for each student? [/INST]

Output: SELECT count(DISTINCT major) ,  count(DISTINCT city_code) FROM student;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the name of dorms which have both TV Lounge and Study Room as amenities. [/INST]

Output: SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge' INTERSECT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'Study Room';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the name of the dorm with both a TV Lounge and Study Room listed as amenities? [/INST]

Output: SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge' INTERSECT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'Study Room';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the name of dorms which have TV Lounge but no Study Room as amenity. [/INST]

Output: SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge' EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'Study Room';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the name of each dorm that has a TV Lounge but no study rooms? [/INST]

Output: SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge' EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'Study Room';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the last name of students who is either female (sex is F) and living in the city of code BAL or male (sex is M) and in age of below 20. [/INST]

Output: SELECT lname FROM student WHERE sex  =  'F' AND city_code  =  'BAL' UNION SELECT lname FROM student WHERE sex  =  'M' AND age  <  20;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the last name of every student who is either female or living in a city with the code BAL or male and under 20? [/INST]

Output: SELECT lname FROM student WHERE sex  =  'F' AND city_code  =  'BAL' UNION SELECT lname FROM student WHERE sex  =  'M' AND age  <  20;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the name of the dorm with the largest capacity. [/INST]

Output: SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the names of the dorm with the largest capacity? [/INST]

Output: SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: List in alphabetic order all different amenities. [/INST]

Output: SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the different dorm amenity names in alphabetical order? [/INST]

Output: SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the code of city where most of students are living in. [/INST]

Output: SELECT city_code FROM student GROUP BY city_code ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

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

Output: SELECT city_code FROM student GROUP BY city_code ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the first and last name of students whose age is younger than the average age. [/INST]

Output: SELECT fname ,  lname FROM student WHERE age  <  (SELECT avg(age) FROM student);


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the first and last name of all students who are younger than average? [/INST]

Output: SELECT fname ,  lname FROM student WHERE age  <  (SELECT avg(age) FROM student);


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: List the first and last name of students who are not living in the city with code HKG, and sorted the results by their ages. [/INST]

Output: SELECT fname ,  lname FROM student WHERE city_code != 'HKG' ORDER BY age;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the first and last names of all students who are not living in the city HKG and order the results by age? [/INST]

Output: SELECT fname ,  lname FROM student WHERE city_code != 'HKG' ORDER BY age;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: List name of all amenities which Anonymous Donor Hall has, and sort the results in alphabetic order. [/INST]

Output: SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T2.amenid  =  T1.amenid JOIN dorm AS T3 ON T2.dormid  =  T3.dormid WHERE T3.dorm_name  =  'Anonymous Donor Hall' ORDER BY T1.amenity_name;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the amenities in alphabetical order that Anonymous Donor Hall has? [/INST]

Output: SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T2.amenid  =  T1.amenid JOIN dorm AS T3 ON T2.dormid  =  T3.dormid WHERE T3.dorm_name  =  'Anonymous Donor Hall' ORDER BY T1.amenity_name;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the number of dorms and total capacity for each gender. [/INST]

Output: SELECT count(*) ,  sum(student_capacity) ,  gender FROM dorm GROUP BY gender;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many dorms are there and what is the total capacity for each gender? [/INST]

Output: SELECT count(*) ,  sum(student_capacity) ,  gender FROM dorm GROUP BY gender;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the average and oldest age for students with different sex. [/INST]

Output: SELECT avg(age) ,  max(age) ,  sex FROM student GROUP BY sex;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the average and oldest age for each gender of student? [/INST]

Output: SELECT avg(age) ,  max(age) ,  sex FROM student GROUP BY sex;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the number of students in each major. [/INST]

Output: SELECT count(*) ,  major FROM student GROUP BY major;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

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

Output: SELECT count(*) ,  major FROM student GROUP BY major;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the number and average age of students living in each city. [/INST]

Output: SELECT count(*) ,  avg(age) ,  city_code FROM student GROUP BY city_code;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many students live in each city and what are their average ages? [/INST]

Output: SELECT count(*) ,  avg(age) ,  city_code FROM student GROUP BY city_code;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the average age and number of male students (with sex M) from each city. [/INST]

Output: SELECT count(*) ,  avg(age) ,  city_code FROM student WHERE sex  =  'M' GROUP BY city_code;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the average age and how many male students are there in each city? [/INST]

Output: SELECT count(*) ,  avg(age) ,  city_code FROM student WHERE sex  =  'M' GROUP BY city_code;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the number of students for the cities where have more than one student. [/INST]

Output: SELECT count(*) ,  city_code FROM student GROUP BY city_code HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many students are from each city, and which cities have more than one cities? [/INST]

Output: SELECT count(*) ,  city_code FROM student GROUP BY city_code HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the first and last name of students who are not in the largest major. [/INST]

Output: SELECT fname ,  lname FROM student WHERE major != (SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1);


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the first and last name of the students who are not in the largest major? [/INST]

Output: SELECT fname ,  lname FROM student WHERE major != (SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1);


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the number of students whose age is older than the average age for each gender. [/INST]

Output: SELECT count(*) ,  sex FROM student WHERE age  >  (SELECT avg(age) FROM student) GROUP BY sex;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many students are older than average for each gender? [/INST]

Output: SELECT count(*) ,  sex FROM student WHERE age  >  (SELECT avg(age) FROM student) GROUP BY sex;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the average age of students living in each dorm and the name of dorm. [/INST]

Output: SELECT avg(T1.age) ,  T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid GROUP BY T3.dorm_name;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the average age for each dorm and what are the names of each dorm? [/INST]

Output: SELECT avg(T1.age) ,  T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid GROUP BY T3.dorm_name;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the number of amenities for each of the dorms that can accommodate more than 100 students. [/INST]

Output: SELECT count(*) ,  T1.dormid FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid WHERE T1.student_capacity  >  100 GROUP BY T1.dormid;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: For each dorm, how many amenities does it have? [/INST]

Output: SELECT count(*) ,  T1.dormid FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid WHERE T1.student_capacity  >  100 GROUP BY T1.dormid;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the number of students who is older than 20 in each dorm. [/INST]

Output: SELECT count(*) ,  T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T1.age  >  20 GROUP BY T3.dorm_name;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many students are older than 20 in each dorm? [/INST]

Output: SELECT count(*) ,  T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T1.age  >  20 GROUP BY T3.dorm_name;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the first name of students who are living in the Smith Hall. [/INST]

Output: SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.dorm_name  =  'Smith Hall';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the first names of all students in Smith Hall? [/INST]

Output: SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.dorm_name  =  'Smith Hall';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the average age of students who are living in the dorm with the largest capacity. [/INST]

Output: SELECT avg(T1.age) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.student_capacity  =  (SELECT max(student_capacity) FROM dorm);


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the average age of students who are living in the dorm with the largest capacity? [/INST]

Output: SELECT avg(T1.age) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.student_capacity  =  (SELECT max(student_capacity) FROM dorm);


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the total number of students living in the male dorm (with gender M). [/INST]

Output: SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.gender  =  'M';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the total number of students who are living in a male dorm? [/INST]

Output: SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.gender  =  'M';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the number of female students (with F sex) living in Smith Hall [/INST]

Output: SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.dorm_name  =  'Smith Hall' AND T1.sex  =  'F';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: How many female students live in Smith Hall? [/INST]

Output: SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid JOIN dorm AS T3 ON T3.dormid  =  T2.dormid WHERE T3.dorm_name  =  'Smith Hall' AND T1.sex  =  'F';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the name of amenities Smith Hall dorm have. [/INST]

Output: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T1.dorm_name  =  'Smith Hall';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the names of the amenities that Smith Hall has? [/INST]

Output: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T1.dorm_name  =  'Smith Hall';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the name of amenities Smith Hall dorm have. ordered the results by amenity names. [/INST]

Output: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T1.dorm_name  =  'Smith Hall' ORDER BY T3.amenity_name;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What amenities does Smith Hall have in alphabetical order? [/INST]

Output: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T1.dorm_name  =  'Smith Hall' ORDER BY T3.amenity_name;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the name of amenity that is most common in all dorms. [/INST]

Output: SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T1.amenid  =  T2.amenid GROUP BY T2.amenid ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the most common amenity in the dorms? [/INST]

Output: SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T1.amenid  =  T2.amenid GROUP BY T2.amenid ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the first name of students who are living in the dorm that has most number of amenities. [/INST]

Output: SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid IN (SELECT T2.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid  =  T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid  =  T5.amenid GROUP BY T3.dormid ORDER BY count(*) DESC LIMIT 1);


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the first names of all students who live in the dorm with the most amenities? [/INST]

Output: SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid IN (SELECT T2.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid  =  T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid  =  T5.amenid GROUP BY T3.dormid ORDER BY count(*) DESC LIMIT 1);


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the name and capacity of the dorm with least number of amenities. [/INST]

Output: SELECT T1.dorm_name ,  T1.student_capacity FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid GROUP BY T2.dormid ORDER BY count(*) LIMIT 1;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the name and capacity of the dorm with the fewest amount of amenities? [/INST]

Output: SELECT T1.dorm_name ,  T1.student_capacity FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid GROUP BY T2.dormid ORDER BY count(*) LIMIT 1;


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the name of dorms that do not have amenity TV Lounge. [/INST]

Output: SELECT dorm_name FROM dorm EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the names of the dorm that does not have a TV Lounge? [/INST]

Output: SELECT dorm_name FROM dorm EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the first and last name of students who are living in the dorms that have amenity TV Lounge. [/INST]

Output: SELECT T1.fname ,  T1.lname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid  =  T4.amenid WHERE T4.amenity_name  =  'TV Lounge');


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the first and last names of all students who are living in a dorm with a TV Lounge? [/INST]

Output: SELECT T1.fname ,  T1.lname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid  =  T4.amenid WHERE T4.amenity_name  =  'TV Lounge');


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the first name and age of students who are living in the dorms that do not have amenity TV Lounge. [/INST]

Output: SELECT T1.fname ,  T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid NOT IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid  =  T4.amenid WHERE T4.amenity_name  =  'TV Lounge');


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What is the first name and age of every student who lives in a dorm with a TV Lounge? [/INST]

Output: SELECT T1.fname ,  T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid  =  T2.stuid WHERE T2.dormid NOT IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid  =  T4.amenid WHERE T4.amenity_name  =  'TV Lounge');


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: Find the name of amenities of the dorm where the student with last name Smith is living in. [/INST]

Output: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid JOIN lives_in AS T4 ON T4.dormid  =  T1.dormid JOIN student AS T5 ON T5.stuid  =  T4.stuid WHERE T5.lname  =  'Smith';


Input:
[INST] Here is a database schema:
Student :
StuID [ INT ] primary_key
LName [ TEXT ]
Fname [ TEXT ]
Age [ INT ]
Sex [ TEXT ]
Major [ INT ]
Advisor [ INT ]
city_code [ TEXT ]

Dorm :
dormid [ INT ]
dorm_name [ TEXT ]
student_capacity [ INT ]
gender [ TEXT ]

Dorm_amenity :
amenid [ INT ]
amenity_name [ TEXT ]

Has_amenity :
dormid [ INT ] Has_amenity.dormid = Dorm.dormid
amenid [ INT ] Has_amenity.amenid = Dorm_amenity.amenid

Lives_in :
stuid [ INT ] Lives_in.stuid = Student.StuID
dormid [ INT ] Lives_in.dormid = Dorm.dormid
room_number [ INT ]

Please write me a SQL statement that answers the following question: What are the amenities in the dorm that a student who has the last name of Smith lives in? [/INST]

Output: SELECT T3.amenity_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid JOIN lives_in AS T4 ON T4.dormid  =  T1.dormid JOIN student AS T5 ON T5.stuid  =  T4.stuid WHERE T5.lname  =  'Smith';


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

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

Output: SELECT count(*) FROM customers;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: Count the number of customers. [/INST]

Output: SELECT count(*) FROM customers;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: Find the emails and phone numbers of all the customers, ordered by email address and phone number. [/INST]

Output: SELECT email_address ,  phone_number FROM customers ORDER BY email_address ,  phone_number;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: What are the emails and phone numbers of all customers, sorted by email address and phone number? [/INST]

Output: SELECT email_address ,  phone_number FROM customers ORDER BY email_address ,  phone_number;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: Which city has the least number of customers whose type code is "Good Credit Rating"? [/INST]

Output: SELECT town_city FROM customers WHERE customer_type_code  =  "Good Credit Rating" GROUP BY town_city ORDER BY count(*) LIMIT 1;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: Return the city with the customer type code "Good Credit Rating" that had the fewest customers. [/INST]

Output: SELECT town_city FROM customers WHERE customer_type_code  =  "Good Credit Rating" GROUP BY town_city ORDER BY count(*) LIMIT 1;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: List the name of all products along with the number of complaints that they have received. [/INST]

Output: SELECT t1.product_name ,  count(*) FROM products AS t1 JOIN complaints AS t2 ON t1.product_id  =  t2.product_id GROUP BY t1.product_name;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: What are all the different product names, and how many complains has each received? [/INST]

Output: SELECT t1.product_name ,  count(*) FROM products AS t1 JOIN complaints AS t2 ON t1.product_id  =  t2.product_id GROUP BY t1.product_name;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: Find the emails of customers who has filed a complaints of the product with the most complaints. [/INST]

Output: SELECT t1.email_address FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id  =  t2.customer_id GROUP BY t1.customer_id ORDER BY count(*) LIMIT 1;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: What are the emails of customers who have filed complaints on the product which has had the greatest number of complaints? [/INST]

Output: SELECT t1.email_address FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id  =  t2.customer_id GROUP BY t1.customer_id ORDER BY count(*) LIMIT 1;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: Which products has been complained by the customer who has filed least amount of complaints? [/INST]

Output: SELECT DISTINCT t1.product_name FROM products AS t1 JOIN complaints AS t2 ON t1.product_id  =  t2.product_id JOIN customers AS t3 GROUP BY t3.customer_id ORDER BY count(*) LIMIT 1;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: Return the names of products that have had complaints filed by the customer who has filed the fewest complaints. [/INST]

Output: SELECT DISTINCT t1.product_name FROM products AS t1 JOIN complaints AS t2 ON t1.product_id  =  t2.product_id JOIN customers AS t3 GROUP BY t3.customer_id ORDER BY count(*) LIMIT 1;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: What is the phone number of the customer who has filed the most recent complaint? [/INST]

Output: SELECT t1.phone_number FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id  =  t2.customer_id ORDER BY t2.date_complaint_raised DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: Return the phone number of the customer who filed the complaint that was raised most recently. [/INST]

Output: SELECT t1.phone_number FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id  =  t2.customer_id ORDER BY t2.date_complaint_raised DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: Find the email and phone number of the customers who have never filed a complaint before. [/INST]

Output: SELECT email_address ,  phone_number FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM complaints);


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: What are the emails and phone numbers of custoemrs who have never filed a complaint? [/INST]

Output: SELECT email_address ,  phone_number FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM complaints);


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: Find the phone number of all the customers and staff. [/INST]

Output: SELECT phone_number FROM customers UNION SELECT phone_number FROM staff;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: What are the phone numbers of all customers and all staff members? [/INST]

Output: SELECT phone_number FROM customers UNION SELECT phone_number FROM staff;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: What is the description of the product named "Chocolate"? [/INST]

Output: SELECT product_description FROM products WHERE product_name  =  "Chocolate";


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: Return the description of the product called "Chocolate". [/INST]

Output: SELECT product_description FROM products WHERE product_name  =  "Chocolate";


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: Find the name and category of the most expensive product. [/INST]

Output: SELECT product_name ,  product_category_code FROM products ORDER BY product_price DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Staff :
staff_id [ INT ] primary_key
gender [ TEXT ]
first_name [ TEXT ]
last_name [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Customers :
customer_id [ INT ] primary_key
customer_type_code [ TEXT ]
address_line_1 [ TEXT ]
address_line_2 [ TEXT ]
town_city [ TEXT ]
state [ TEXT ]
email_address [ TEXT ]
phone_number [ TEXT ]

Products :
product_id [ INT ] primary_key
parent_product_id [ INT ]
product_category_code [ TEXT ]
date_product_first_available [ TEXT ]
date_product_discontinued [ TEXT ]
product_name [ TEXT ]
product_description [ TEXT ]
product_price [ INT ]

Complaints :
complaint_id [ INT ]
product_id [ INT ] Complaints.product_id = Products.product_id
customer_id [ INT ] Complaints.customer_id = Customers.customer_id
complaint_outcome_code [ TEXT ]
complaint_status_code [ TEXT ]
complaint_type_code [ TEXT ]
date_complaint_raised [ TEXT ]
date_complaint_closed [ TEXT ]
staff_id [ INT ] Complaints.staff_id = Staff.staff_id

Please write me a SQL statement that answers the following question: What is the name and category code of the product with the highest price? [/INST]

Output: SELECT product_name ,  product_category_code FROM products ORDER BY product_price DESC LIMIT 1;