Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find the ids and first names of the 3 teachers that have the most number of assessment notes? [/INST]

Output: SELECT T1.teacher_id ,  T2.first_name FROM Assessment_Notes AS T1 JOIN Teachers AS T2 ON T1.teacher_id  =  T2.teacher_id GROUP BY T1.teacher_id ORDER BY count(*) DESC LIMIT 3;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find the id and last name of the student that has the most behavior incidents? [/INST]

Output: SELECT T1.student_id ,  T2.last_name FROM Behavior_Incident AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find the id and last name of the teacher that has the most detentions with detention type code "AFTER"? [/INST]

Output: SELECT T1.teacher_id ,  T2.last_name FROM Detention AS T1 JOIN Teachers AS T2 ON T1.teacher_id  =  T2.teacher_id WHERE T1.detention_type_code  =  "AFTER" GROUP BY T1.teacher_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What are the id and first name of the student whose addresses have the highest average monthly rental? [/INST]

Output: SELECT T1.student_id ,  T2.first_name FROM Student_Addresses AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id GROUP BY T1.student_id ORDER BY AVG(monthly_rental) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find the id and city of the student address with the highest average monthly rental. [/INST]

Output: SELECT T2.address_id ,  T1.city FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id  =  T2.address_id GROUP BY T2.address_id ORDER BY AVG(monthly_rental) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What are the code and description of the most frequent behavior incident type? [/INST]

Output: SELECT T1.incident_type_code ,  T2.incident_type_description FROM Behavior_Incident AS T1 JOIN Ref_Incident_Type AS T2 ON T1.incident_type_code  =  T2.incident_type_code GROUP BY T1.incident_type_code ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What are the code and description of the least frequent detention type ? [/INST]

Output: SELECT T1.detention_type_code ,  T2.detention_type_description FROM Detention AS T1 JOIN Ref_Detention_Type AS T2 ON T1.detention_type_code  =  T2.detention_type_code GROUP BY T1.detention_type_code ORDER BY count(*) ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find the dates of assessment notes for students with first name "Fanny". [/INST]

Output: SELECT T1.date_of_notes FROM Assessment_Notes AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id WHERE T2.first_name  =  "Fanny";


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find the texts of assessment notes for teachers with last name "Schuster". [/INST]

Output: SELECT T1.text_of_notes FROM Assessment_Notes AS T1 JOIN Teachers AS T2 ON T1.teacher_id  =  T2.teacher_id WHERE T2.last_name  =  "Schuster";


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find the start and end dates of behavior incidents of students with last name "Fahey". [/INST]

Output: SELECT T1.date_incident_start ,  date_incident_end FROM Behavior_Incident AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id WHERE T2.last_name  =  "Fahey";


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find the start and end dates of detentions of teachers with last name "Schultz". [/INST]

Output: SELECT T1.datetime_detention_start ,  datetime_detention_end FROM Detention AS T1 JOIN Teachers AS T2 ON T1.teacher_id  =  T2.teacher_id WHERE T2.last_name  =  "Schultz";


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What are the id and zip code of the address with the highest monthly rental? [/INST]

Output: SELECT T2.address_id ,  T1.zip_postcode FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id  =  T2.address_id ORDER BY monthly_rental DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What is the cell phone number of the student whose address has the lowest monthly rental? [/INST]

Output: SELECT T2.cell_mobile_number FROM Student_Addresses AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id ORDER BY T1.monthly_rental ASC LIMIT 1;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What are the monthly rentals of student addresses in Texas state? [/INST]

Output: SELECT T2.monthly_rental FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id  =  T2.address_id WHERE T1.state_province_county  =  "Texas";


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What are the first names and last names of students with address in Wisconsin state? [/INST]

Output: SELECT T2.first_name ,  T2.last_name FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id  =  T2.address_id WHERE T1.state_province_county  =  "Wisconsin";


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What are the line 1 and average monthly rentals of all student addresses? [/INST]

Output: SELECT T1.line_1 ,  avg(T2.monthly_rental) FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id  =  T2.address_id GROUP BY T2.address_id;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What is the zip code of the address where the teacher with first name "Lyla" lives? [/INST]

Output: SELECT T1.zip_postcode FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id  =  T2.address_id WHERE T2.first_name  =  "Lyla";


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What are the email addresses of teachers whose address has zip code "918"? [/INST]

Output: SELECT T2.email_address FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id  =  T2.address_id WHERE T1.zip_postcode  =  "918";


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: How many students are not involved in any behavior incident? [/INST]

Output: SELECT count(*) FROM STUDENTS WHERE student_id NOT IN ( SELECT student_id FROM Behavior_Incident );


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find the last names of teachers who are not involved in any detention. [/INST]

Output: SELECT last_name FROM Teachers EXCEPT SELECT T1.last_name FROM Teachers AS T1 JOIN Detention AS T2 ON T1.teacher_id  =  T2.teacher_id;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What are the line 1 of addresses shared by some students and some teachers? [/INST]

Output: SELECT T1.line_1 FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id  =  T2.address_id INTERSECT SELECT T1.line_1 FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id  =  T2.address_id;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which assets have 2 parts and have less than 2 fault logs? List the asset id and detail. [/INST]

Output: SELECT T1.asset_id ,  T1.asset_details FROM Assets AS T1 JOIN Asset_Parts AS T2 ON T1.asset_id  =  T2.asset_id GROUP BY T1.asset_id HAVING count(*)  =  2 INTERSECT SELECT T1.asset_id ,  T1.asset_details FROM Assets AS T1 JOIN Fault_Log AS T2 ON T1.asset_id  =  T2.asset_id GROUP BY T1.asset_id HAVING count(*)  <  2;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: How many assets does each maintenance contract contain? List the number and the contract id. [/INST]

Output: SELECT count(*) ,  T1.maintenance_contract_id FROM Maintenance_Contracts AS T1 JOIN Assets AS T2 ON T1.maintenance_contract_id  =  T2.maintenance_contract_id GROUP BY T1.maintenance_contract_id;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: How many assets does each third party company supply? List the count and the company id. [/INST]

Output: SELECT count(*) ,  T1.company_id FROM Third_Party_Companies AS T1 JOIN Assets AS T2 ON T1.company_id  =  T2.supplier_company_id GROUP BY T1.company_id;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which third party companies have at least 2 maintenance engineers or have at least 2 maintenance contracts? List the company id and name. [/INST]

Output: SELECT T1.company_id ,  T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Engineers AS T2 ON T1.company_id  =  T2.company_id GROUP BY T1.company_id HAVING count(*)  >=  2 UNION SELECT T3.company_id ,  T3.company_name FROM Third_Party_Companies AS T3 JOIN Maintenance_Contracts AS T4 ON T3.company_id  =  T4.maintenance_contract_company_id GROUP BY T3.company_id HAVING count(*)  >=  2;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: What is the name and id of the staff who recorded the fault log but has not contacted any visiting engineers? [/INST]

Output: SELECT T1.staff_name ,  T1.staff_id FROM Staff AS T1 JOIN Fault_Log AS T2 ON T1.staff_id  =  T2.recorded_by_staff_id EXCEPT SELECT T3.staff_name ,  T3.staff_id FROM Staff AS T3 JOIN Engineer_Visits AS T4 ON T3.staff_id  =  T4.contact_staff_id;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which engineer has visited the most times? Show the engineer id, first name and last name. [/INST]

Output: SELECT T1.engineer_id ,  T1.first_name ,  T1.last_name FROM Maintenance_Engineers AS T1 JOIN Engineer_Visits AS T2 GROUP BY T1.engineer_id ORDER BY count(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: Which parts have more than 2 faults? Show the part name and id. [/INST]

Output: SELECT T1.part_name ,  T1.part_id FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id  =  T2.part_id GROUP BY T1.part_id HAVING count(*)  >  2;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: List all every engineer's first name, last name, details and coresponding skill description. [/INST]

Output: SELECT T1.first_name ,  T1.last_name ,  T1.other_details ,  T3.skill_description FROM Maintenance_Engineers AS T1 JOIN Engineer_Skills AS T2 ON T1.engineer_id  =  T2.engineer_id JOIN Skills AS T3 ON T2.skill_id  =  T3.skill_id;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: For all the faults of different parts, what are all the decriptions of the skills required to fix them? List the name of the faults and the skill description. [/INST]

Output: SELECT T1.fault_short_name ,  T3.skill_description FROM Part_Faults AS T1 JOIN Skills_Required_To_Fix AS T2 ON T1.part_fault_id  =  T2.part_fault_id JOIN Skills AS T3 ON T2.skill_id  =  T3.skill_id;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: How many assets can each parts be used in? List the part name and the number. [/INST]

Output: SELECT T1.part_name ,  count(*) FROM Parts AS T1 JOIN Asset_Parts AS T2 ON T1.part_id  =  T2.part_id GROUP BY T1.part_name;


Input:
[INST] Here is a database schema:
Third_Party_Companies :
company_id [ INT ] primary_key
company_type [ TEXT ]
company_name [ TEXT ]
company_address [ TEXT ]
other_company_details [ TEXT ]

Maintenance_Contracts :
maintenance_contract_id [ INT ] primary_key
maintenance_contract_company_id [ INT ] Maintenance_Contracts.maintenance_contract_company_id = Third_Party_Companies.company_id
contract_start_date [ TEXT ]
contract_end_date [ TEXT ]
other_contract_details [ TEXT ]

Parts :
part_id [ INT ] primary_key
part_name [ TEXT ]
chargeable_yn [ TEXT ]
chargeable_amount [ TEXT ]
other_part_details [ TEXT ]

Skills :
skill_id [ INT ] primary_key
skill_code [ TEXT ]
skill_description [ TEXT ]

Staff :
staff_id [ INT ] primary_key
staff_name [ TEXT ]
gender [ TEXT ]
other_staff_details [ TEXT ]

Assets :
asset_id [ INT ] primary_key
maintenance_contract_id [ INT ] Assets.maintenance_contract_id = Maintenance_Contracts.maintenance_contract_id
supplier_company_id [ INT ] Assets.supplier_company_id = Third_Party_Companies.company_id
asset_details [ TEXT ]
asset_make [ TEXT ]
asset_model [ TEXT ]
asset_acquired_date [ TEXT ]
asset_disposed_date [ TEXT ]
other_asset_details [ TEXT ]

Asset_Parts :
asset_id [ INT ] Asset_Parts.asset_id = Assets.asset_id
part_id [ INT ] Asset_Parts.part_id = Parts.part_id

Maintenance_Engineers :
engineer_id [ INT ] primary_key
company_id [ INT ] Maintenance_Engineers.company_id = Third_Party_Companies.company_id
first_name [ TEXT ]
last_name [ TEXT ]
other_details [ TEXT ]

Engineer_Skills :
engineer_id [ INT ] Engineer_Skills.engineer_id = Maintenance_Engineers.engineer_id
skill_id [ INT ] Engineer_Skills.skill_id = Skills.skill_id

Fault_Log :
fault_log_entry_id [ INT ] primary_key
asset_id [ INT ] Fault_Log.asset_id = Assets.asset_id
recorded_by_staff_id [ INT ] Fault_Log.recorded_by_staff_id = Staff.staff_id
fault_log_entry_datetime [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Engineer_Visits :
engineer_visit_id [ INT ] primary_key
contact_staff_id [ INT ] Engineer_Visits.contact_staff_id = Staff.staff_id
engineer_id [ INT ] Engineer_Visits.engineer_id = Maintenance_Engineers.engineer_id
fault_log_entry_id [ INT ] Engineer_Visits.fault_log_entry_id = Fault_Log.fault_log_entry_id
fault_status [ TEXT ]
visit_start_datetime [ TEXT ]
visit_end_datetime [ TEXT ]
other_visit_details [ TEXT ]

Part_Faults :
part_fault_id [ INT ] primary_key
part_id [ INT ] Part_Faults.part_id = Parts.part_id
fault_short_name [ TEXT ]
fault_description [ TEXT ]
other_fault_details [ TEXT ]

Fault_Log_Parts :
fault_log_entry_id [ INT ] Fault_Log_Parts.fault_log_entry_id = Fault_Log.fault_log_entry_id
part_fault_id [ INT ] Fault_Log_Parts.part_fault_id = Part_Faults.part_fault_id
fault_status [ TEXT ]

Skills_Required_To_Fix :
part_fault_id [ INT ] Skills_Required_To_Fix.part_fault_id = Part_Faults.part_fault_id
skill_id [ INT ] Skills_Required_To_Fix.skill_id = Skills.skill_id

Please write me a SQL statement that answers the following question: What are all the fault descriptions and the fault status of all the faults recoreded in the logs? [/INST]

Output: SELECT T1.fault_description ,  T2.fault_status FROM Fault_Log AS T1 JOIN Fault_Log_Parts AS T2 ON T1.fault_log_entry_id  =  T2.fault_log_entry_id;