Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: What are the three most costly procedures? [/INST]

Output: SELECT name FROM procedures ORDER BY cost LIMIT 3;


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Find the physicians who are trained in a procedure that costs more than 5000. [/INST]

Output: SELECT T1.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T3.cost  >  5000;


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Which physicians are trained in procedures that are more expensive than 5000? [/INST]

Output: SELECT T1.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T3.cost  >  5000;


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Find the physician who was trained in the most expensive procedure? [/INST]

Output: SELECT T1.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment ORDER BY T3.cost DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Which physician was trained in the procedure that costs the most. [/INST]

Output: SELECT T1.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment ORDER BY T3.cost DESC LIMIT 1;


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: What is the average cost of procedures that physician John Wen was trained in? [/INST]

Output: SELECT avg(T3.cost) FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen";


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Compute the mean price of procedures physician John Wen was trained in. [/INST]

Output: SELECT avg(T3.cost) FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen";


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Find the names of procedures which physician John Wen was trained in. [/INST]

Output: SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen";


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: What are the names of procedures physician John Wen was trained in? [/INST]

Output: SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen";


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Find all procedures which cost more than 1000 or which physician John Wen was trained in. [/INST]

Output: SELECT name FROM procedures WHERE cost  >  1000 UNION SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen";


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: What are the procedures that cost more than 1000 or are specialized in by physician John Wen? [/INST]

Output: SELECT name FROM procedures WHERE cost  >  1000 UNION SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen";


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Find the names of all procedures which cost more than 1000 but which physician John Wen was not trained in? [/INST]

Output: SELECT name FROM procedures WHERE cost  >  1000 EXCEPT SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen";


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Among the procedures that cost more than 1000, which were not specialized in by physician John Wen? [/INST]

Output: SELECT name FROM procedures WHERE cost  >  1000 EXCEPT SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen";


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Find the names of all procedures such that the cost is less than 5000 and physician John Wen was trained in. [/INST]

Output: SELECT name FROM procedures WHERE cost  <  5000 INTERSECT SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen";


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: What procedures cost less than 5000 and have John Wen as a trained physician? [/INST]

Output: SELECT name FROM procedures WHERE cost  <  5000 INTERSECT SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen";


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Find the name of physicians who are affiliated with both Surgery and Psychiatry departments. [/INST]

Output: SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID  =  T2.physician JOIN department AS T3 ON T2.department  =  T3.DepartmentID WHERE T3.name  =  'Surgery' INTERSECT SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID  =  T2.physician JOIN department AS T3 ON T2.department  =  T3.DepartmentID WHERE T3.name  =  'Psychiatry';


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Which physicians are affiliated with both Surgery and Psychiatry departments? Tell me their names. [/INST]

Output: SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID  =  T2.physician JOIN department AS T3 ON T2.department  =  T3.DepartmentID WHERE T3.name  =  'Surgery' INTERSECT SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID  =  T2.physician JOIN department AS T3 ON T2.department  =  T3.DepartmentID WHERE T3.name  =  'Psychiatry';


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Find the name of physicians who are affiliated with Surgery or Psychiatry department. [/INST]

Output: SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID  =  T2.physician JOIN department AS T3 ON T2.department  =  T3.DepartmentID WHERE T3.name  =  'Surgery' OR T3.name  =  'Psychiatry';


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Which physicians are affiliated with either Surgery or Psychiatry department? Give me their names. [/INST]

Output: SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID  =  T2.physician JOIN department AS T3 ON T2.department  =  T3.DepartmentID WHERE T3.name  =  'Surgery' OR T3.name  =  'Psychiatry';


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Find the names of patients who are not using the medication of Procrastin-X. [/INST]

Output: SELECT name FROM patient EXCEPT SELECT T1.name FROM patient AS T1 JOIN Prescribes AS T2 ON T2.Patient  =  T1.SSN JOIN Medication AS T3 ON T2.Medication  =  T3.Code WHERE T3.name  =  'Procrastin-X';


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: What are the names of patients who are not taking the medication of Procrastin-X. [/INST]

Output: SELECT name FROM patient EXCEPT SELECT T1.name FROM patient AS T1 JOIN Prescribes AS T2 ON T2.Patient  =  T1.SSN JOIN Medication AS T3 ON T2.Medication  =  T3.Code WHERE T3.name  =  'Procrastin-X';


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Find the number of patients who are not using the medication of Procrastin-X. [/INST]

Output: SELECT count(*) FROM patient WHERE SSN NOT IN ( SELECT T1.patient FROM Prescribes AS T1 JOIN Medication AS T2 ON T1.Medication  =  T2.Code WHERE T2.name  =  'Procrastin-X' );


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: How many patients are not using Procrastin-X as medication? [/INST]

Output: SELECT count(*) FROM patient WHERE SSN NOT IN ( SELECT T1.patient FROM Prescribes AS T1 JOIN Medication AS T2 ON T1.Medication  =  T2.Code WHERE T2.name  =  'Procrastin-X' );


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

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

Output: SELECT count(*) FROM appointment;


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Count how many appointments have been made in total. [/INST]

Output: SELECT count(*) FROM appointment;


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: Find the names of nurses who are on call. [/INST]

Output: SELECT DISTINCT T1.name FROM nurse AS T1 JOIN on_call AS T2 ON T1.EmployeeID  =  T2.nurse;


Input:
[INST] Here is a database schema:
Physician :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
SSN [ INT ]

Department :
DepartmentID [ INT ] primary_key
Name [ TEXT ]
Head [ INT ] Department.Head = Physician.EmployeeID

Affiliated_With :
Physician [ INT ] primary_key Affiliated_With.Physician = Physician.EmployeeID
Department [ INT ] Affiliated_With.Department = Department.DepartmentID
PrimaryAffiliation [ TEXT ]

Procedures :
Code [ INT ] primary_key
Name [ TEXT ]
Cost [ INT ]

Trained_In :
Physician [ INT ] primary_key Trained_In.Physician = Physician.EmployeeID
Treatment [ INT ] Trained_In.Treatment = Procedures.Code
CertificationDate [ TEXT ]
CertificationExpires [ TEXT ]

Patient :
SSN [ INT ] primary_key
Name [ TEXT ]
Address [ TEXT ]
Phone [ TEXT ]
InsuranceID [ INT ]
PCP [ INT ] Patient.PCP = Physician.EmployeeID

Nurse :
EmployeeID [ INT ] primary_key
Name [ TEXT ]
Position [ TEXT ]
Registered [ TEXT ]
SSN [ INT ]

Appointment :
AppointmentID [ INT ] primary_key
Patient [ INT ] Appointment.Patient = Patient.SSN
PrepNurse [ INT ] Appointment.PrepNurse = Nurse.EmployeeID
Physician [ INT ] Appointment.Physician = Physician.EmployeeID
Start [ TEXT ]
End [ TEXT ]
ExaminationRoom [ TEXT ]

Medication :
Code [ INT ] primary_key
Name [ TEXT ]
Brand [ TEXT ]
Description [ TEXT ]

Prescribes :
Physician [ INT ] primary_key Prescribes.Physician = Physician.EmployeeID
Patient [ INT ] Prescribes.Patient = Patient.SSN
Medication [ INT ] Prescribes.Medication = Medication.Code
Date [ TEXT ]
Appointment [ INT ] Prescribes.Appointment = Appointment.AppointmentID
Dose [ TEXT ]

Block :
BlockFloor [ INT ] primary_key
BlockCode [ INT ]

Room :
RoomNumber [ INT ] primary_key
RoomType [ TEXT ]
BlockFloor [ INT ] Room.BlockFloor = Block.BlockFloor
BlockCode [ INT ] Room.BlockCode = Block.BlockCode
Unavailable [ TEXT ]

On_Call :
Nurse [ INT ] primary_key On_Call.Nurse = Nurse.EmployeeID
BlockFloor [ INT ] On_Call.BlockFloor = Block.BlockFloor
BlockCode [ INT ] On_Call.BlockCode = Block.BlockCode
OnCallStart [ TEXT ]
OnCallEnd [ TEXT ]

Stay :
StayID [ INT ] primary_key
Patient [ INT ] Stay.Patient = Patient.SSN
Room [ INT ] Stay.Room = Room.RoomNumber
StayStart [ TEXT ]
StayEnd [ TEXT ]

Undergoes :
Patient [ INT ] primary_key Undergoes.Patient = Patient.SSN
Procedures [ INT ] Undergoes.Procedures = Procedures.Code
Stay [ INT ] Undergoes.Stay = Stay.StayID
DateUndergoes [ TEXT ]
Physician [ INT ] Undergoes.Physician = Physician.EmployeeID
AssistingNurse [ INT ] Undergoes.AssistingNurse = Nurse.EmployeeID

Please write me a SQL statement that answers the following question: What are the distinct names of nurses on call? [/INST]

Output: SELECT DISTINCT T1.name FROM nurse AS T1 JOIN on_call AS T2 ON T1.EmployeeID  =  T2.nurse;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

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

Output: SELECT count(*) FROM ship;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

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

Output: SELECT count(*) FROM ship;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: List the name of ships in ascending order of tonnage. [/INST]

Output: SELECT Name FROM ship ORDER BY Tonnage ASC;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: what are the names of the ships ordered by ascending tonnage? [/INST]

Output: SELECT Name FROM ship ORDER BY Tonnage ASC;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

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

Output: SELECT TYPE ,  Nationality FROM ship;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: What are the types and nationalities of every ship? [/INST]

Output: SELECT TYPE ,  Nationality FROM ship;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: List the name of ships whose nationality is not "United States". [/INST]

Output: SELECT Name FROM ship WHERE Nationality != "United States";


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: What are the names of the ships that are not from the United States? [/INST]

Output: SELECT Name FROM ship WHERE Nationality != "United States";


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: Show the name of ships whose nationality is either United States or United Kingdom. [/INST]

Output: SELECT Name FROM ship WHERE Nationality  =  "United States" OR Nationality  =  "United Kingdom";


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: What are the names of the ships  that are from either the US or the UK? [/INST]

Output: SELECT Name FROM ship WHERE Nationality  =  "United States" OR Nationality  =  "United Kingdom";


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: What is the name of the ship with the largest tonnage? [/INST]

Output: SELECT Name FROM ship ORDER BY Tonnage DESC LIMIT 1;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: What is the ship with the largest amount of tonnage called? [/INST]

Output: SELECT Name FROM ship ORDER BY Tonnage DESC LIMIT 1;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: Show different types of ships and the number of ships of each type. [/INST]

Output: SELECT TYPE ,  COUNT(*) FROM ship GROUP BY TYPE;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: For each type, how many ships are there? [/INST]

Output: SELECT TYPE ,  COUNT(*) FROM ship GROUP BY TYPE;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: Please show the most common type of ships. [/INST]

Output: SELECT TYPE FROM ship GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: What is the most common type of ships? [/INST]

Output: SELECT TYPE FROM ship GROUP BY TYPE ORDER BY COUNT(*) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: List the nations that have more than two ships. [/INST]

Output: SELECT Nationality FROM ship GROUP BY Nationality HAVING COUNT(*)  >  2;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: What are the nations that have more than two ships? [/INST]

Output: SELECT Nationality FROM ship GROUP BY Nationality HAVING COUNT(*)  >  2;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: Show different types of ships and the average tonnage of ships of each type. [/INST]

Output: SELECT TYPE ,  avg(Tonnage) FROM ship GROUP BY TYPE;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: For each type, what is the average tonnage? [/INST]

Output: SELECT TYPE ,  avg(Tonnage) FROM ship GROUP BY TYPE;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: Show codes and fates of missions, and names of ships involved. [/INST]

Output: SELECT T1.Code ,  T1.Fate ,  T2.Name FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID  =  T2.Ship_ID;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: What are the mission codes, fates, and names of the ships involved? [/INST]

Output: SELECT T1.Code ,  T1.Fate ,  T2.Name FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID  =  T2.Ship_ID;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: Show names of ships involved in a mission launched after 1928. [/INST]

Output: SELECT T2.Name FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID  =  T2.Ship_ID WHERE T1.Launched_Year  >  1928;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: What are the names of ships that were involved in a mission launched after 1928? [/INST]

Output: SELECT T2.Name FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID  =  T2.Ship_ID WHERE T1.Launched_Year  >  1928;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: Show the distinct fate of missions that involve ships with nationality "United States" [/INST]

Output: SELECT DISTINCT T1.Fate FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID  =  T2.Ship_ID WHERE T2.Nationality  =  "United States";


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: What are the different fates of the mission that involved ships from the United States? [/INST]

Output: SELECT DISTINCT T1.Fate FROM mission AS T1 JOIN ship AS T2 ON T1.Ship_ID  =  T2.Ship_ID WHERE T2.Nationality  =  "United States";


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: List the name of ships that are not involved in any mission [/INST]

Output: SELECT Name FROM ship WHERE Ship_ID NOT IN (SELECT Ship_ID FROM mission);


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: What are the names of the ships that are not involved in any missions? [/INST]

Output: SELECT Name FROM ship WHERE Ship_ID NOT IN (SELECT Ship_ID FROM mission);


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: Show the types of ships that have both ships with tonnage larger than 6000 and ships with tonnage smaller than 4000. [/INST]

Output: SELECT TYPE FROM ship WHERE Tonnage  >  6000 INTERSECT SELECT TYPE FROM ship WHERE Tonnage  <  4000;


Input:
[INST] Here is a database schema:
mission :
Mission_ID [ INT ] primary_key
Ship_ID [ INT ] mission.Ship_ID = ship.Ship_ID
Code [ TEXT ]
Launched_Year [ INT ]
Location [ TEXT ]
Speed_knots [ INT ]
Fate [ TEXT ]

ship :
Ship_ID [ INT ] primary_key
Name [ TEXT ]
Type [ TEXT ]
Nationality [ TEXT ]
Tonnage [ INT ]

Please write me a SQL statement that answers the following question: What are the types of the ships that have both shiips with tonnage more than 6000 and those with tonnage less than 4000? [/INST]

Output: SELECT TYPE FROM ship WHERE Tonnage  >  6000 INTERSECT SELECT TYPE FROM ship WHERE Tonnage  <  4000;


Input:
[INST] Here is a database schema:
list :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Grade [ INT ]
Classroom [ INT ]

teachers :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Classroom [ INT ]

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

Output: SELECT count(*) FROM list;


Input:
[INST] Here is a database schema:
list :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Grade [ INT ]
Classroom [ INT ]

teachers :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Classroom [ INT ]

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

Output: SELECT count(*) FROM list;


Input:
[INST] Here is a database schema:
list :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Grade [ INT ]
Classroom [ INT ]

teachers :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Classroom [ INT ]

Please write me a SQL statement that answers the following question: Find the last names of students studying in room 111. [/INST]

Output: SELECT lastname FROM list WHERE classroom  =  111;


Input:
[INST] Here is a database schema:
list :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Grade [ INT ]
Classroom [ INT ]

teachers :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Classroom [ INT ]

Please write me a SQL statement that answers the following question: What are the last names of students in room 111? [/INST]

Output: SELECT lastname FROM list WHERE classroom  =  111;


Input:
[INST] Here is a database schema:
list :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Grade [ INT ]
Classroom [ INT ]

teachers :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Classroom [ INT ]

Please write me a SQL statement that answers the following question: Find the first names of students studying in room 108. [/INST]

Output: SELECT firstname FROM list WHERE classroom  =  108;


Input:
[INST] Here is a database schema:
list :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Grade [ INT ]
Classroom [ INT ]

teachers :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Classroom [ INT ]

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

Output: SELECT firstname FROM list WHERE classroom  =  108;


Input:
[INST] Here is a database schema:
list :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Grade [ INT ]
Classroom [ INT ]

teachers :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Classroom [ INT ]

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

Output: SELECT DISTINCT firstname FROM list WHERE classroom  =  107;


Input:
[INST] Here is a database schema:
list :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Grade [ INT ]
Classroom [ INT ]

teachers :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Classroom [ INT ]

Please write me a SQL statement that answers the following question: List the first names of all the students in room 107. [/INST]

Output: SELECT DISTINCT firstname FROM list WHERE classroom  =  107;


Input:
[INST] Here is a database schema:
list :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Grade [ INT ]
Classroom [ INT ]

teachers :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Classroom [ INT ]

Please write me a SQL statement that answers the following question: For each classroom report the grade that is taught in it. Report just the classroom number and the grade number. [/INST]

Output: SELECT DISTINCT classroom ,  grade FROM list;


Input:
[INST] Here is a database schema:
list :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Grade [ INT ]
Classroom [ INT ]

teachers :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Classroom [ INT ]

Please write me a SQL statement that answers the following question: What are the grade number and classroom number of each class in the list? [/INST]

Output: SELECT DISTINCT classroom ,  grade FROM list;


Input:
[INST] Here is a database schema:
list :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Grade [ INT ]
Classroom [ INT ]

teachers :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Classroom [ INT ]

Please write me a SQL statement that answers the following question: Which grade is studying in classroom 103? [/INST]

Output: SELECT DISTINCT grade FROM list WHERE classroom  =  103;


Input:
[INST] Here is a database schema:
list :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Grade [ INT ]
Classroom [ INT ]

teachers :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Classroom [ INT ]

Please write me a SQL statement that answers the following question: Find the grade taught in classroom 103. [/INST]

Output: SELECT DISTINCT grade FROM list WHERE classroom  =  103;


Input:
[INST] Here is a database schema:
list :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Grade [ INT ]
Classroom [ INT ]

teachers :
LastName [ TEXT ] primary_key
FirstName [ TEXT ]
Classroom [ INT ]

Please write me a SQL statement that answers the following question: Find the grade studying in room 105. [/INST]

Output: SELECT DISTINCT grade FROM list WHERE classroom  =  105;