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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: What are the name of courses that have at least five enrollments? [/INST]

Output: SELECT T1.CName FROM COURSE AS T1 JOIN ENROLLED_IN AS T2 ON T1.CID  =  T2.CID GROUP BY T2.CID HAVING COUNT(*)  >=  5;


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: Give the names of the courses with at least five enrollments. [/INST]

Output: SELECT T1.CName FROM COURSE AS T1 JOIN ENROLLED_IN AS T2 ON T1.CID  =  T2.CID GROUP BY T2.CID HAVING COUNT(*)  >=  5;


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: Find the first name and last name of the instructor of course that has course name [/INST]

Output: SELECT T2.Fname ,  T2.Lname FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor  =  T2.FacID WHERE T1.CName  =  "COMPUTER LITERACY";


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: What is the full name of the instructor who has a course named COMPUTER LITERACY? [/INST]

Output: SELECT T2.Fname ,  T2.Lname FROM COURSE AS T1 JOIN FACULTY AS T2 ON T1.Instructor  =  T2.FacID WHERE T1.CName  =  "COMPUTER LITERACY";


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: Find the department name and room of the course INTRODUCTION TO COMPUTER SCIENCE. [/INST]

Output: SELECT T2.Dname ,  T2.Room FROM COURSE AS T1 JOIN DEPARTMENT AS T2 ON T1.DNO  =  T2.DNO WHERE T1.CName  =  "INTRODUCTION TO COMPUTER SCIENCE";


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: What are the department name and room for the course INTRODUCTION TO COMPUTER SCIENCE? [/INST]

Output: SELECT T2.Dname ,  T2.Room FROM COURSE AS T1 JOIN DEPARTMENT AS T2 ON T1.DNO  =  T2.DNO WHERE T1.CName  =  "INTRODUCTION TO COMPUTER SCIENCE";


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: Find the student first and last names and grade points of all enrollments. [/INST]

Output: SELECT T3.Fname ,  T3.LName ,  T2.gradepoint FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade  =  T2.lettergrade AND T1.StuID  =  T3.StuID;


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: What are the full names and gradepoints for all enrollments? [/INST]

Output: SELECT T3.Fname ,  T3.LName ,  T2.gradepoint FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade  =  T2.lettergrade AND T1.StuID  =  T3.StuID;


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: Find the distinct student first names of all students that have grade point at least 3.8 in one course. [/INST]

Output: SELECT DISTINCT T3.Fname FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade  =  T2.lettergrade AND T1.StuID  =  T3.StuID WHERE T2.gradepoint  >=  3.8;


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: What are the distinct first names for students with a grade point of 3.8 or above in at least one course? [/INST]

Output: SELECT DISTINCT T3.Fname FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade  =  T2.lettergrade AND T1.StuID  =  T3.StuID WHERE T2.gradepoint  >=  3.8;


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: Find the full names of faculties who are members of department with department number 520. [/INST]

Output: SELECT T1.Fname ,  T1.Lname FROM FACULTY AS T1 JOIN MEMBER_OF AS T2 ON T1.FacID  =  T2.FacID WHERE T2.DNO  =  520;


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: What are the full names of faculty members who are a part of department 520? [/INST]

Output: SELECT T1.Fname ,  T1.Lname FROM FACULTY AS T1 JOIN MEMBER_OF AS T2 ON T1.FacID  =  T2.FacID WHERE T2.DNO  =  520;


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: What are the first names and last names of the students that minor in the department with DNO 140. [/INST]

Output: SELECT T2.Fname ,  T2.Lname FROM MINOR_IN AS T1 JOIN STUDENT AS T2 ON T1.StuID  =  T2.StuID WHERE T1.DNO  =  140;


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: What are the full names of students minoring in department 140? [/INST]

Output: SELECT T2.Fname ,  T2.Lname FROM MINOR_IN AS T1 JOIN STUDENT AS T2 ON T1.StuID  =  T2.StuID WHERE T1.DNO  =  140;


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: Find the last names of faculties who are members of computer science department. [/INST]

Output: SELECT T2.Lname FROM DEPARTMENT AS T1 JOIN FACULTY AS T2 ON T1.DNO  =  T3.DNO JOIN MEMBER_OF AS T3 ON T2.FacID  =  T3.FacID WHERE T1.DName  =  "Computer Science";


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: What are the last names of faculty who are part of the computer science department? [/INST]

Output: SELECT T2.Lname FROM DEPARTMENT AS T1 JOIN FACULTY AS T2 ON T1.DNO  =  T3.DNO JOIN MEMBER_OF AS T3 ON T2.FacID  =  T3.FacID WHERE T1.DName  =  "Computer Science";


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: Find the average grade point of student whose last name is Smith. [/INST]

Output: SELECT avg(T2.gradepoint) FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade  =  T2.lettergrade AND T1.StuID  =  T3.StuID WHERE T3.LName  =  "Smith";


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: What is the average gradepoint for students with the last name Smith? [/INST]

Output: SELECT avg(T2.gradepoint) FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade  =  T2.lettergrade AND T1.StuID  =  T3.StuID WHERE T3.LName  =  "Smith";


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: What is the maximum and minimum grade point of students who live in NYC? [/INST]

Output: SELECT max(T2.gradepoint) ,  min(T2.gradepoint) FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade  =  T2.lettergrade AND T1.StuID  =  T3.StuID WHERE T3.city_code  =  "NYC";


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: Give the maximum and minimum gradepoints for students living in NYC? [/INST]

Output: SELECT max(T2.gradepoint) ,  min(T2.gradepoint) FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade  =  T2.lettergrade AND T1.StuID  =  T3.StuID WHERE T3.city_code  =  "NYC";


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: Find the names of courses that have either 3 credits or 1 credit but 4 hours. [/INST]

Output: SELECT CName FROM COURSE WHERE Credits  =  3 UNION SELECT CName FROM COURSE WHERE Credits  =  1 AND Hours  =  4;


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: What are the names of courses that give either 3 credits, or 1 credit and 4 hours? [/INST]

Output: SELECT CName FROM COURSE WHERE Credits  =  3 UNION SELECT CName FROM COURSE WHERE Credits  =  1 AND Hours  =  4;


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: Find the names of departments that are either in division AS or in division EN and in Building NEB. [/INST]

Output: SELECT DName FROM DEPARTMENT WHERE Division  =  "AS" UNION SELECT DName FROM DEPARTMENT WHERE Division  =  "EN" AND Building  =  "NEB";


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: What are the names of departments either in division AS, or in division EN and in building NEB? [/INST]

Output: SELECT DName FROM DEPARTMENT WHERE Division  =  "AS" UNION SELECT DName FROM DEPARTMENT WHERE Division  =  "EN" AND Building  =  "NEB";


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

Please write me a SQL statement that answers the following question: Find the first name of students not enrolled in any course. [/INST]

Output: SELECT Fname FROM STUDENT WHERE StuID NOT IN (SELECT StuID FROM ENROLLED_IN);


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

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

Department :
DNO [ INT ] primary_key
Division [ TEXT ]
DName [ TEXT ]
Room [ TEXT ]
Building [ TEXT ]
DPhone [ INT ]

Member_of :
FacID [ INT ] Member_of.FacID = Faculty.FacID
DNO [ INT ] Member_of.DNO = Department.DNO
Appt_Type [ TEXT ]

Course :
CID [ TEXT ] primary_key
CName [ TEXT ]
Credits [ INT ]
Instructor [ INT ] Course.Instructor = Faculty.FacID
Days [ TEXT ]
Hours [ TEXT ]
DNO [ INT ] Course.DNO = Department.DNO

Minor_in :
StuID [ INT ] Minor_in.StuID = Student.StuID
DNO [ INT ] Minor_in.DNO = Department.DNO

Enrolled_in :
StuID [ INT ] Enrolled_in.StuID = Student.StuID
CID [ TEXT ] Enrolled_in.CID = Course.CID
Grade [ TEXT ] Enrolled_in.Grade = Gradeconversion.lettergrade

Gradeconversion :
lettergrade [ TEXT ] primary_key
gradepoint [ INT ]

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

Output: SELECT Fname FROM STUDENT WHERE StuID NOT IN (SELECT StuID FROM ENROLLED_IN);


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the ids of the top three products that were purchased in the largest amount? [/INST]

Output: SELECT product_id FROM product_suppliers ORDER BY total_amount_purchased DESC LIMIT 3;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Give the ids of the three products purchased in the largest amounts. [/INST]

Output: SELECT product_id FROM product_suppliers ORDER BY total_amount_purchased DESC LIMIT 3;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the product id and product type of the cheapest product? [/INST]

Output: SELECT product_id ,  product_type_code FROM products ORDER BY product_price LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Give the id and product type of the product with the lowest price. [/INST]

Output: SELECT product_id ,  product_type_code FROM products ORDER BY product_price LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

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

Output: SELECT count(DISTINCT product_type_code) FROM products;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

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

Output: SELECT count(DISTINCT product_type_code) FROM products;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Return the address of customer 10. [/INST]

Output: SELECT T1.address_details FROM addresses AS T1 JOIN customer_addresses AS T2 ON T1.address_id  =  T2.address_id WHERE T2.customer_id  =  10;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What is the address for the customer with id 10? [/INST]

Output: SELECT T1.address_details FROM addresses AS T1 JOIN customer_addresses AS T2 ON T1.address_id  =  T2.address_id WHERE T2.customer_id  =  10;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the staff ids and genders of all staffs whose job title is Department Manager? [/INST]

Output: SELECT T1.staff_id ,  T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id  =  T2.staff_id WHERE T2.job_title_code  =  "Department Manager";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Return the staff ids and genders for any staff with the title Department Manager. [/INST]

Output: SELECT T1.staff_id ,  T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id  =  T2.staff_id WHERE T2.job_title_code  =  "Department Manager";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: For each payment method, return how many customers use it. [/INST]

Output: SELECT payment_method_code ,  count(*) FROM customers GROUP BY payment_method_code;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: How many customers use each payment method? [/INST]

Output: SELECT payment_method_code ,  count(*) FROM customers GROUP BY payment_method_code;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What is the id of the product that was ordered the most often? [/INST]

Output: SELECT product_id FROM order_items GROUP BY product_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Give the product id for the product that was ordered most frequently. [/INST]

Output: SELECT product_id FROM order_items GROUP BY product_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What are the name, phone number and email address of the customer who made the largest number of orders? [/INST]

Output: SELECT T1.customer_name ,  T1.customer_phone ,  T1.customer_email FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T2.customer_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Return the name, phone number and email address for the customer with the most orders. [/INST]

Output: SELECT T1.customer_name ,  T1.customer_phone ,  T1.customer_email FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T2.customer_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What is the average price for each type of product? [/INST]

Output: SELECT product_type_code ,  avg(product_price) FROM products GROUP BY product_type_code;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Return the average price for each product type. [/INST]

Output: SELECT product_type_code ,  avg(product_price) FROM products GROUP BY product_type_code;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: How many department stores does the store chain South have? [/INST]

Output: SELECT count(*) FROM department_stores AS T1 JOIN department_store_chain AS T2 ON T1.dept_store_chain_id  =  T2.dept_store_chain_id WHERE T2.dept_store_chain_name  =  "South";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

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

Output: SELECT count(*) FROM department_stores AS T1 JOIN department_store_chain AS T2 ON T1.dept_store_chain_id  =  T2.dept_store_chain_id WHERE T2.dept_store_chain_name  =  "South";


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: What is the name and job title of the staff who was assigned the latest? [/INST]

Output: SELECT T1.staff_name ,  T2.job_title_code FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id  =  T2.staff_id ORDER BY T2.date_assigned_to DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Return the name and job title of the staff with the latest date assigned. [/INST]

Output: SELECT T1.staff_name ,  T2.job_title_code FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id  =  T2.staff_id ORDER BY T2.date_assigned_to DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Addresses :
address_id [ INT ] primary_key
address_details [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_gender [ TEXT ]
staff_name [ TEXT ]

Suppliers :
supplier_id [ INT ] primary_key
supplier_name [ TEXT ]
supplier_phone [ TEXT ]

Department_Store_Chain :
dept_store_chain_id [ INT ] primary_key
dept_store_chain_name [ TEXT ]

Customers :
customer_id [ INT ] primary_key
payment_method_code [ TEXT ]
customer_code [ TEXT ]
customer_name [ TEXT ]
customer_address [ TEXT ]
customer_phone [ TEXT ]
customer_email [ TEXT ]

Products :
product_id [ INT ] primary_key
product_type_code [ TEXT ]
product_name [ TEXT ]
product_price [ INT ]

Supplier_Addresses :
supplier_id [ INT ] primary_key Supplier_Addresses.supplier_id = Suppliers.supplier_id
address_id [ INT ] Supplier_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Addresses :
customer_id [ INT ] primary_key Customer_Addresses.customer_id = Customers.customer_id
address_id [ INT ] Customer_Addresses.address_id = Addresses.address_id
date_from [ TEXT ]
date_to [ TEXT ]

Customer_Orders :
order_id [ INT ] primary_key
customer_id [ INT ] Customer_Orders.customer_id = Customers.customer_id
order_status_code [ TEXT ]
order_date [ TEXT ]

Department_Stores :
dept_store_id [ INT ] primary_key
dept_store_chain_id [ INT ] Department_Stores.dept_store_chain_id = Department_Store_Chain.dept_store_chain_id
store_name [ TEXT ]
store_address [ TEXT ]
store_phone [ TEXT ]
store_email [ TEXT ]

Departments :
department_id [ INT ] primary_key
dept_store_id [ INT ] Departments.dept_store_id = Department_Stores.dept_store_id
department_name [ TEXT ]

Order_Items :
order_item_id [ INT ] primary_key
order_id [ INT ] Order_Items.order_id = Customer_Orders.order_id
product_id [ INT ] Order_Items.product_id = Products.product_id

Product_Suppliers :
product_id [ INT ] primary_key Product_Suppliers.product_id = Products.product_id
supplier_id [ INT ] Product_Suppliers.supplier_id = Suppliers.supplier_id
date_supplied_from [ TEXT ]
date_supplied_to [ TEXT ]
total_amount_purchased [ TEXT ]
total_value_purchased [ INT ]

Staff_Department_Assignments :
staff_id [ INT ] primary_key Staff_Department_Assignments.staff_id = Staff.staff_id
department_id [ INT ] Staff_Department_Assignments.department_id = Departments.department_id
date_assigned_from [ TEXT ]
job_title_code [ TEXT ]
date_assigned_to [ TEXT ]

Please write me a SQL statement that answers the following question: Give me the product type, name and price for all the products supplied by supplier id 3. [/INST]

Output: SELECT T2.product_type_code ,  T2.product_name ,  T2.product_price FROM product_suppliers AS T1 JOIN products AS T2 ON T1.product_id  =  T2.product_id WHERE T1.supplier_id  =  3;