Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT count(*) FROM Student;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT Fname ,  Lname FROM Student;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the full names of all students [/INST]

Output: SELECT Fname ,  Lname FROM Student;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT count(DISTINCT advisor) FROM Student;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT count(DISTINCT advisor) FROM Student;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show all majors. [/INST]

Output: SELECT DISTINCT Major FROM Student;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the different majors? [/INST]

Output: SELECT DISTINCT Major FROM Student;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show all cities where students live. [/INST]

Output: SELECT DISTINCT city_code FROM Student;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What cities do students live in? [/INST]

Output: SELECT DISTINCT city_code FROM Student;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show first name, last name, age for all female students. Their sex is F. [/INST]

Output: SELECT Fname ,  Lname ,  Age FROM Student WHERE Sex  =  'F';


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the full names and ages for all female students whose sex is F? [/INST]

Output: SELECT Fname ,  Lname ,  Age FROM Student WHERE Sex  =  'F';


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show student ids for all male students. [/INST]

Output: SELECT StuID FROM Student WHERE Sex  =  'M';


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the student ids for all male students? [/INST]

Output: SELECT StuID FROM Student WHERE Sex  =  'M';


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT count(*) FROM Student WHERE age  =  18;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT count(*) FROM Student WHERE age  =  18;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show all student ids who are older than 20. [/INST]

Output: SELECT StuID FROM Student WHERE age  >  20;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the student ids for students over 20 years old? [/INST]

Output: SELECT StuID FROM Student WHERE age  >  20;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Which city does the student whose last name is "Kim" live in? [/INST]

Output: SELECT city_code FROM Student WHERE LName  =  "Kim";


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Give the city that the student whose family name is Kim lives in. [/INST]

Output: SELECT city_code FROM Student WHERE LName  =  "Kim";


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Who is the advisor of student with ID 1004? [/INST]

Output: SELECT Advisor FROM Student WHERE StuID  =  1004;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Who advises student 1004? [/INST]

Output: SELECT Advisor FROM Student WHERE StuID  =  1004;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: How many students live in HKG or CHI? [/INST]

Output: SELECT count(*) FROM Student WHERE city_code  =  "HKG" OR city_code  =  "CHI";


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Give the number of students living in either HKG or CHI. [/INST]

Output: SELECT count(*) FROM Student WHERE city_code  =  "HKG" OR city_code  =  "CHI";


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show the minimum, average, and maximum age of all students. [/INST]

Output: SELECT min(age) ,  avg(age) ,  max(age) FROM Student;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What is the minimum, mean, and maximum age across all students? [/INST]

Output: SELECT min(age) ,  avg(age) ,  max(age) FROM Student;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What is the last name of the youngest student? [/INST]

Output: SELECT LName FROM Student WHERE age  =  (SELECT min(age) FROM Student);


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Provide the last name of the youngest student. [/INST]

Output: SELECT LName FROM Student WHERE age  =  (SELECT min(age) FROM Student);


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show the student id of the oldest student. [/INST]

Output: SELECT StuID FROM Student WHERE age  =  (SELECT max(age) FROM Student);


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What student id corresponds to the oldest student? [/INST]

Output: SELECT StuID FROM Student WHERE age  =  (SELECT max(age) FROM Student);


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show all majors and corresponding number of students. [/INST]

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


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

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


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT major FROM Student GROUP BY major ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What is the largest major? [/INST]

Output: SELECT major FROM Student GROUP BY major ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show all ages and corresponding number of students. [/INST]

Output: SELECT age ,  count(*) FROM Student GROUP BY age;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: How old is each student and how many students are each age? [/INST]

Output: SELECT age ,  count(*) FROM Student GROUP BY age;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show the average age for male and female students. [/INST]

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


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the average ages for male and female students? [/INST]

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


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show all cities and corresponding number of students. [/INST]

Output: SELECT city_code ,  count(*) FROM Student GROUP BY city_code;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT city_code ,  count(*) FROM Student GROUP BY city_code;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show all advisors and corresponding number of students. [/INST]

Output: SELECT advisor ,  count(*) FROM Student GROUP BY advisor;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT advisor ,  count(*) FROM Student GROUP BY advisor;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT advisor FROM Student GROUP BY advisor ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Give the advisor with the most students. [/INST]

Output: SELECT advisor FROM Student GROUP BY advisor ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT count(*) FROM Has_allergy WHERE Allergy  =  "Cat";


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: How many students are affected by cat allergies? [/INST]

Output: SELECT count(*) FROM Has_allergy WHERE Allergy  =  "Cat";


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show all student IDs who have at least two allergies. [/INST]

Output: SELECT StuID FROM Has_allergy GROUP BY StuID HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the students ids of students who have more than one allergy? [/INST]

Output: SELECT StuID FROM Has_allergy GROUP BY StuID HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the student ids of students who don't have any allergies? [/INST]

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


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Which students are unaffected by allergies? [/INST]

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


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: How many female students have milk or egg allergies? [/INST]

Output: SELECT count(*) FROM has_allergy AS T1 JOIN Student AS T2 ON T1.StuID  =  T2.StuID WHERE T2.sex  =  "F" AND T1.allergy  =  "Milk" OR T1.allergy  =  "Eggs";


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: How many students who are female are allergic to milk or eggs? [/INST]

Output: SELECT count(*) FROM has_allergy AS T1 JOIN Student AS T2 ON T1.StuID  =  T2.StuID WHERE T2.sex  =  "F" AND T1.allergy  =  "Milk" OR T1.allergy  =  "Eggs";


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT count(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy  =  T2.allergy WHERE T2.allergytype  =  "food";


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: How many students are affected by food related allergies? [/INST]

Output: SELECT count(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy  =  T2.allergy WHERE T2.allergytype  =  "food";


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT Allergy FROM Has_allergy GROUP BY Allergy ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Which allergy is the most common? [/INST]

Output: SELECT Allergy FROM Has_allergy GROUP BY Allergy ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show all allergies with number of students affected. [/INST]

Output: SELECT Allergy ,  count(*) FROM Has_allergy GROUP BY Allergy;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT Allergy ,  count(*) FROM Has_allergy GROUP BY Allergy;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Show all allergy type with number of students affected. [/INST]

Output: SELECT T2.allergytype ,  count(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy  =  T2.allergy GROUP BY T2.allergytype;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: How many students are affected by each allergy type? [/INST]

Output: SELECT T2.allergytype ,  count(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy  =  T2.allergy GROUP BY T2.allergytype;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Find the last name and age of the student who has allergy to both milk and cat. [/INST]

Output: SELECT lname ,  age FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy  =  "Milk" INTERSECT SELECT StuID FROM Has_allergy WHERE Allergy  =  "Cat");


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the last names and ages of the students who are allergic to milk and cat? [/INST]

Output: SELECT lname ,  age FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy  =  "Milk" INTERSECT SELECT StuID FROM Has_allergy WHERE Allergy  =  "Cat");


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the allergies and their types that the student with first name Lisa has? And order the result by name of allergies. [/INST]

Output: SELECT T1.Allergy ,  T1.AllergyType FROM Allergy_type AS T1 JOIN Has_allergy AS T2 ON T1.Allergy  =  T2.Allergy JOIN Student AS T3 ON T3.StuID  =  T2.StuID WHERE T3.Fname  =  "Lisa" ORDER BY T1.Allergy;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the allergies the girl named Lisa has? And what are the types of them? Order the result by allergy names. [/INST]

Output: SELECT T1.Allergy ,  T1.AllergyType FROM Allergy_type AS T1 JOIN Has_allergy AS T2 ON T1.Allergy  =  T2.Allergy JOIN Student AS T3 ON T3.StuID  =  T2.StuID WHERE T3.Fname  =  "Lisa" ORDER BY T1.Allergy;


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Find the first name and gender of the student who has allergy to milk but not cat. [/INST]

Output: SELECT fname ,  sex FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy  =  "Milk" EXCEPT SELECT StuID FROM Has_allergy WHERE Allergy  =  "Cat");


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the first name and gender of the students who have allergy to milk but can put up with cats? [/INST]

Output: SELECT fname ,  sex FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy  =  "Milk" EXCEPT SELECT StuID FROM Has_allergy WHERE Allergy  =  "Cat");


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Find the average age of the students who have allergies with food and animal types. [/INST]

Output: SELECT avg(age) FROM Student WHERE StuID IN ( SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food" INTERSECT SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "animal");


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: How old are the students with allergies to food and animal types on average? [/INST]

Output: SELECT avg(age) FROM Student WHERE StuID IN ( SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food" INTERSECT SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "animal");


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: List the first and last name of the students who do not have any food type allergy. [/INST]

Output: SELECT fname ,  lname FROM Student WHERE StuID NOT IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food");


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What is the full name of each student who is not allergic to any type of food. [/INST]

Output: SELECT fname ,  lname FROM Student WHERE StuID NOT IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food");


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Find the number of male (sex is 'M') students who have some food type allery. [/INST]

Output: SELECT count(*) FROM Student WHERE sex  =  "M" AND StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food");


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: How many male students (sex is 'M') are allergic to any type of food? [/INST]

Output: SELECT count(*) FROM Student WHERE sex  =  "M" AND StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food");


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Find the different first names and cities of the students who have allergy to milk or cat. [/INST]

Output: SELECT DISTINCT T1.fname ,  T1.city_code FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.stuid  =  T2.stuid WHERE T2.Allergy  =  "Milk" OR T2.Allergy  =  "Cat";


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the distinct first names and cities of the students who have allergy either to milk or to cat? [/INST]

Output: SELECT DISTINCT T1.fname ,  T1.city_code FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.stuid  =  T2.stuid WHERE T2.Allergy  =  "Milk" OR T2.Allergy  =  "Cat";


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: Find the number of students who are older than 18 and do not have allergy to either food or animal. [/INST]

Output: SELECT count(*) FROM Student WHERE age  >  18 AND StuID NOT IN ( SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food" OR T2.allergytype  =  "animal");


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: How many students are over 18 and do not have allergy to food type or animal type? [/INST]

Output: SELECT count(*) FROM Student WHERE age  >  18 AND StuID NOT IN ( SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food" OR T2.allergytype  =  "animal");


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

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

Output: SELECT fname ,  major FROM Student WHERE StuID NOT IN (SELECT StuID FROM Has_allergy WHERE Allergy  =  "Soy");


Input:
[INST] Here is a database schema:
Allergy_Type :
Allergy [ TEXT ] primary_key
AllergyType [ TEXT ]

Has_Allergy :
StuID [ INT ] Has_Allergy.StuID = Student.StuID
Allergy [ TEXT ] Has_Allergy.Allergy = Allergy_Type.Allergy

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

Please write me a SQL statement that answers the following question: What are the first name and major of the students who are able to consume soy? [/INST]

Output: SELECT fname ,  major FROM Student WHERE StuID NOT IN (SELECT StuID FROM Has_allergy WHERE Allergy  =  "Soy");


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: A list of the top 5 countries by number of invoices. List country name and number of invoices. [/INST]

Output: SELECT billing_country ,  COUNT(*) FROM invoices GROUP BY billing_country ORDER BY count(*) DESC LIMIT 5;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: What are the top 5 countries by number of invoices and how many do they have? [/INST]

Output: SELECT billing_country ,  COUNT(*) FROM invoices GROUP BY billing_country ORDER BY count(*) DESC LIMIT 5;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: A list of the top 8 countries by gross/total invoice size. List country name and gross invoice size. [/INST]

Output: SELECT billing_country ,  SUM(total) FROM invoices GROUP BY billing_country ORDER BY SUM(total) DESC LIMIT 8;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: What are the names of the top 8 countries by total invoice size and what are those sizes? [/INST]

Output: SELECT billing_country ,  SUM(total) FROM invoices GROUP BY billing_country ORDER BY SUM(total) DESC LIMIT 8;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: A list of the top 10 countries by average invoice size. List country name and average invoice size. [/INST]

Output: SELECT billing_country ,  AVG(total) FROM invoices GROUP BY billing_country ORDER BY AVG(total) DESC LIMIT 10;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: What are the names of the countries and average invoice size of the top countries by size? [/INST]

Output: SELECT billing_country ,  AVG(total) FROM invoices GROUP BY billing_country ORDER BY AVG(total) DESC LIMIT 10;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: Find out 5 customers who most recently purchased something. List customers' first and last name. [/INST]

Output: SELECT T1.first_name ,  T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id  =  T1.id ORDER BY T2.invoice_date DESC LIMIT 5;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: What are the first and last names of the 5 customers who purchased something most recently? [/INST]

Output: SELECT T1.first_name ,  T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id  =  T1.id ORDER BY T2.invoice_date DESC LIMIT 5;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: Find out the top 10 customers by total number of orders. List customers' first and last name and the number of total orders. [/INST]

Output: SELECT T1.first_name ,  T1.last_name ,  COUNT(*) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id  =  T1.id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 10;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: What are the top 10 customers' first and last names by total number of orders and how many orders did they make? [/INST]

Output: SELECT T1.first_name ,  T1.last_name ,  COUNT(*) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id  =  T1.id GROUP BY T1.id ORDER BY COUNT(*) DESC LIMIT 10;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: List the top 10 customers by total gross sales. List customers' first and last name and total gross sales. [/INST]

Output: SELECT T1.first_name ,  T1.last_name ,  SUM(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id  =  T1.id GROUP BY T1.id ORDER BY SUM(T2.total) DESC LIMIT 10;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: What are the top 10 customers' first and last names with the highest gross sales, and also what are the sales? [/INST]

Output: SELECT T1.first_name ,  T1.last_name ,  SUM(T2.total) FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id  =  T1.id GROUP BY T1.id ORDER BY SUM(T2.total) DESC LIMIT 10;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: List the top 5 genres by number of tracks. List genres name and total tracks. [/INST]

Output: SELECT T1.name ,  COUNT(*) FROM genres AS T1 JOIN tracks AS T2 ON T2.genre_id  =  T1.id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 5;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: How many tracks does each genre have and what are the names of the top 5? [/INST]

Output: SELECT T1.name ,  COUNT(*) FROM genres AS T1 JOIN tracks AS T2 ON T2.genre_id  =  T1.id GROUP BY T1.id ORDER BY count(*) DESC LIMIT 5;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: List every album's title. [/INST]

Output: SELECT title FROM albums;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: What are the titles of all the albums? [/INST]

Output: SELECT title FROM albums;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: List every album ordered by album title in ascending order. [/INST]

Output: SELECT title FROM albums ORDER BY title;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: What are the titles of all the albums alphabetically ascending? [/INST]

Output: SELECT title FROM albums ORDER BY title;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: List every album whose title starts with A in alphabetical order. [/INST]

Output: SELECT title FROM albums WHERE title LIKE 'A%' ORDER BY title;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: What are the titles of all albums that start with A in alphabetical order? [/INST]

Output: SELECT title FROM albums WHERE title LIKE 'A%' ORDER BY title;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: List the customers first and last name of 10 least expensive invoices. [/INST]

Output: SELECT T1.first_name ,  T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id  =  T1.id ORDER BY total LIMIT 10;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: What are the first and last names of the customers with the 10 cheapest invoices? [/INST]

Output: SELECT T1.first_name ,  T1.last_name FROM customers AS T1 JOIN invoices AS T2 ON T2.customer_id  =  T1.id ORDER BY total LIMIT 10;


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: List total amount of  invoice from Chicago, IL. [/INST]

Output: SELECT sum(total) FROM invoices WHERE billing_city  =  "Chicago" AND billing_state  =  "IL";


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: What are the total amount of money in the invoices billed from Chicago, Illinois? [/INST]

Output: SELECT sum(total) FROM invoices WHERE billing_city  =  "Chicago" AND billing_state  =  "IL";


Input:
[INST] Here is a database schema:
artists :
id [ INT ] primary_key
name [ TEXT ]

sqlite_sequence :
name [ TEXT ]
seq [ TEXT ]

albums :
id [ INT ] primary_key
title [ TEXT ]
artist_id [ INT ] albums.artist_id = artists.id

employees :
id [ INT ] primary_key
last_name [ TEXT ]
first_name [ TEXT ]
title [ TEXT ]
reports_to [ INT ] employees.reports_to = employees.id
birth_date [ TEXT ]
hire_date [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]

customers :
id [ INT ] primary_key
first_name [ TEXT ]
last_name [ TEXT ]
company [ TEXT ]
address [ TEXT ]
city [ TEXT ]
state [ TEXT ]
country [ TEXT ]
postal_code [ TEXT ]
phone [ TEXT ]
fax [ TEXT ]
email [ TEXT ]
support_rep_id [ INT ] customers.support_rep_id = employees.id

genres :
id [ INT ] primary_key
name [ TEXT ]

invoices :
id [ INT ] primary_key
customer_id [ INT ] invoices.customer_id = customers.id
invoice_date [ TEXT ]
billing_address [ TEXT ]
billing_city [ TEXT ]
billing_state [ TEXT ]
billing_country [ TEXT ]
billing_postal_code [ TEXT ]
total [ INT ]

media_types :
id [ INT ] primary_key
name [ TEXT ]

tracks :
id [ INT ] primary_key
name [ TEXT ]
album_id [ INT ] tracks.album_id = albums.id
media_type_id [ INT ] tracks.media_type_id = media_types.id
genre_id [ INT ] tracks.genre_id = genres.id
composer [ TEXT ]
milliseconds [ INT ]
bytes [ INT ]
unit_price [ INT ]

invoice_lines :
id [ INT ] primary_key
invoice_id [ INT ] invoice_lines.invoice_id = invoices.id
track_id [ INT ] invoice_lines.track_id = tracks.id
unit_price [ INT ]
quantity [ INT ]

playlists :
id [ INT ] primary_key
name [ TEXT ]

playlist_tracks :
playlist_id [ INT ] primary_key playlist_tracks.playlist_id = playlists.id
track_id [ INT ] playlist_tracks.track_id = tracks.id

Please write me a SQL statement that answers the following question: List the number of invoices from Chicago, IL. [/INST]

Output: SELECT COUNT(*) FROM invoices WHERE billing_city  =  "Chicago" AND billing_state  =  "IL";