db_name
stringclasses 146
values | prompt
stringlengths 310
4.81k
|
|---|---|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What is the employee id of the head whose department has the least number of employees?
#
### SQL:
#
# SELECT head FROM department GROUP BY departmentID ORDER BY count(departmentID) LIMIT 1;
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Tell me the employee id of the head of the department with the least employees.
#
### SQL:
#
# SELECT head FROM department GROUP BY departmentID ORDER BY count(departmentID) LIMIT 1;
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# what is the name and position of the head whose department has least number of employees?
#
### SQL:
#
# SELECT T2.name , T2.position FROM department AS T1 JOIN physician AS T2 ON T1.head = T2.EmployeeID GROUP BY departmentID ORDER BY count(departmentID) LIMIT 1;
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the name and position of the head of the department with the least employees.
#
### SQL:
#
# SELECT T2.name , T2.position FROM department AS T1 JOIN physician AS T2 ON T1.head = T2.EmployeeID GROUP BY departmentID ORDER BY count(departmentID) LIMIT 1;
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are names of patients who made an appointment?
#
### SQL:
#
# SELECT name FROM appointment AS T1 JOIN patient AS T2 ON T1.patient = T2.ssn
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# List the names of patients who have made appointments.
#
### SQL:
#
# SELECT name FROM appointment AS T1 JOIN patient AS T2 ON T1.patient = T2.ssn
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# what are name and phone number of patients who had more than one appointment?
#
### SQL:
#
# SELECT name , phone FROM appointment AS T1 JOIN patient AS T2 ON T1.patient = T2.ssn GROUP BY T1.patient HAVING count(*) > 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Which patients made more than one appointment? Tell me the name and phone number of these patients.
#
### SQL:
#
# SELECT name , phone FROM appointment AS T1 JOIN patient AS T2 ON T1.patient = T2.ssn GROUP BY T1.patient HAVING count(*) > 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the id of the appointment with the most recent start date?
#
### SQL:
#
# SELECT appointmentid FROM appointment ORDER BY START DESC LIMIT 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What is the id of the appointment that started most recently?
#
### SQL:
#
# SELECT appointmentid FROM appointment ORDER BY START DESC LIMIT 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# List the name of physicians who took some appointment.
#
### SQL:
#
# SELECT T2.name FROM appointment AS T1 JOIN physician AS T2 ON T1.Physician = T2.EmployeeID
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are the names of all the physicians who took appointments.
#
### SQL:
#
# SELECT T2.name FROM appointment AS T1 JOIN physician AS T2 ON T1.Physician = T2.EmployeeID
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# List the name of physicians who never took any appointment.
#
### SQL:
#
# SELECT name FROM physician EXCEPT SELECT T2.name FROM appointment AS T1 JOIN physician AS T2 ON T1.Physician = T2.EmployeeID
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Which physicians have never taken any appointment? Find their names.
#
### SQL:
#
# SELECT name FROM physician EXCEPT SELECT T2.name FROM appointment AS T1 JOIN physician AS T2 ON T1.Physician = T2.EmployeeID
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the names of all physicians and their primary affiliated departments' names.
#
### SQL:
#
# SELECT T1.name , T3.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 T2.PrimaryAffiliation = 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are the name and primarily affiliated department name of each physician?
#
### SQL:
#
# SELECT T1.name , T3.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 T2.PrimaryAffiliation = 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What is the name of the patient who made the most recent appointment?
#
### SQL:
#
# SELECT T1.name FROM patient AS T1 JOIN appointment AS T2 ON T1.ssn = T2.patient ORDER BY T2.start DESC LIMIT 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the name of the patient who made the appointment with the most recent start date.
#
### SQL:
#
# SELECT T1.name FROM patient AS T1 JOIN appointment AS T2 ON T1.ssn = T2.patient ORDER BY T2.start DESC LIMIT 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# How many patients stay in room 112?
#
### SQL:
#
# SELECT count(patient) FROM stay WHERE room = 112
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Count the number of patients who stayed in room 112.
#
### SQL:
#
# SELECT count(patient) FROM stay WHERE room = 112
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# How many patients' prescriptions are made by physician John Dorian?
#
### SQL:
#
# SELECT count(T1.SSN) FROM patient AS T1 JOIN prescribes AS T2 ON T1.SSN = T2.patient JOIN physician AS T3 ON T2.physician = T3.employeeid WHERE T3.name = "John Dorian"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the number of patients' prescriptions physician John Dorian made.
#
### SQL:
#
# SELECT count(T1.SSN) FROM patient AS T1 JOIN prescribes AS T2 ON T1.SSN = T2.patient JOIN physician AS T3 ON T2.physician = T3.employeeid WHERE T3.name = "John Dorian"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the name of medication used on the patient who stays in room 111?
#
### SQL:
#
# SELECT T4.name FROM stay AS T1 JOIN patient AS T2 ON T1.Patient = T2.SSN JOIN Prescribes AS T3 ON T3.Patient = T2.SSN JOIN Medication AS T4 ON T3.Medication = T4.Code WHERE room = 111
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What is the name of the medication used for the patient staying in room 111?
#
### SQL:
#
# SELECT T4.name FROM stay AS T1 JOIN patient AS T2 ON T1.Patient = T2.SSN JOIN Prescribes AS T3 ON T3.Patient = T2.SSN JOIN Medication AS T4 ON T3.Medication = T4.Code WHERE room = 111
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the patient who most recently stayed in room 111.
#
### SQL:
#
# SELECT patient FROM stay WHERE room = 111 ORDER BY staystart DESC LIMIT 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What is the id of the patient who stayed in room 111 most recently?
#
### SQL:
#
# SELECT patient FROM stay WHERE room = 111 ORDER BY staystart DESC LIMIT 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What is the name of the nurse has the most appointments?
#
### SQL:
#
# SELECT T1.name FROM nurse AS T1 JOIN appointment AS T2 ON T1.employeeid = T2.prepnurse GROUP BY T1.employeeid ORDER BY count(*) DESC LIMIT 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the name of the nurse who has the largest number of appointments.
#
### SQL:
#
# SELECT T1.name FROM nurse AS T1 JOIN appointment AS T2 ON T1.employeeid = T2.prepnurse GROUP BY T1.employeeid ORDER BY count(*) DESC LIMIT 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# How many patients do each physician take care of? List their names and number of patients they take care of.
#
### SQL:
#
# SELECT T1.name , count(*) FROM physician AS T1 JOIN patient AS T2 ON T1.employeeid = T2.PCP GROUP BY T1.employeeid
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Return the name of each physician and the number of patients he or she treats.
#
### SQL:
#
# SELECT T1.name , count(*) FROM physician AS T1 JOIN patient AS T2 ON T1.employeeid = T2.PCP GROUP BY T1.employeeid
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the name of physicians who are in charge of more than one patient.
#
### SQL:
#
# SELECT T1.name FROM physician AS T1 JOIN patient AS T2 ON T1.employeeid = T2.PCP GROUP BY T1.employeeid HAVING count(*) > 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Which physicians are in charge of more than one patient? Give me their names.
#
### SQL:
#
# SELECT T1.name FROM physician AS T1 JOIN patient AS T2 ON T1.employeeid = T2.PCP GROUP BY T1.employeeid HAVING count(*) > 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the number of rooms located on each block floor.
#
### SQL:
#
# SELECT count(*) , T1.blockfloor FROM BLOCK AS T1 JOIN room AS T2 ON T1.blockfloor = T2.blockfloor AND T1.blockcode = T2.blockcode GROUP BY T1.blockfloor
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# How many rooms does each block floor have?
#
### SQL:
#
# SELECT count(*) , T1.blockfloor FROM BLOCK AS T1 JOIN room AS T2 ON T1.blockfloor = T2.blockfloor AND T1.blockcode = T2.blockcode GROUP BY T1.blockfloor
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the number of rooms for different block code?
#
### SQL:
#
# SELECT count(*) , T1.blockcode FROM BLOCK AS T1 JOIN room AS T2 ON T1.blockfloor = T2.blockfloor AND T1.blockcode = T2.blockcode GROUP BY T1.blockcode
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# How many rooms are located for each block code?
#
### SQL:
#
# SELECT count(*) , T1.blockcode FROM BLOCK AS T1 JOIN room AS T2 ON T1.blockfloor = T2.blockfloor AND T1.blockcode = T2.blockcode GROUP BY T1.blockcode
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are the unique block codes that have available rooms?
#
### SQL:
#
# SELECT DISTINCT blockcode FROM room WHERE unavailable = 0
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Tell me the distinct block codes where some rooms are available.
#
### SQL:
#
# SELECT DISTINCT blockcode FROM room WHERE unavailable = 0
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# How many different types of rooms are there?
#
### SQL:
#
# SELECT count(DISTINCT roomtype) FROM room
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the number of distinct room types available.
#
### SQL:
#
# SELECT count(DISTINCT roomtype) FROM room
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What is the names of the physicians who prescribe medication Thesisin?
#
### SQL:
#
# SELECT DISTINCT T1.name FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician JOIN medication AS T3 ON T3.code = T2.medication WHERE T3.name = "Thesisin"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# List the names of all the physicians who prescribe Thesisin as medication.
#
### SQL:
#
# SELECT DISTINCT T1.name FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician JOIN medication AS T3 ON T3.code = T2.medication WHERE T3.name = "Thesisin"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the name and position of physicians who prescribe some medication whose brand is X?
#
### SQL:
#
# SELECT DISTINCT T1.name , T1.position FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician JOIN medication AS T3 ON T3.code = T2.medication WHERE T3.Brand = "X"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Which physicians prescribe a medication of brand X? Tell me the name and position of those physicians.
#
### SQL:
#
# SELECT DISTINCT T1.name , T1.position FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician JOIN medication AS T3 ON T3.code = T2.medication WHERE T3.Brand = "X"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the number of medications prescribed for each brand.
#
### SQL:
#
# SELECT count(*) , T1.name FROM medication AS T1 JOIN prescribes AS T2 ON T1.code = T2.medication GROUP BY T1.brand
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# How many medications are prescribed for each brand?
#
### SQL:
#
# SELECT count(*) , T1.name FROM medication AS T1 JOIN prescribes AS T2 ON T1.code = T2.medication GROUP BY T1.brand
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the name of physicians whose position title contains the word 'senior'.
#
### SQL:
#
# SELECT name FROM physician WHERE POSITION LIKE '%senior%'
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are the names of the physicians who have 'senior' in their titles.
#
### SQL:
#
# SELECT name FROM physician WHERE POSITION LIKE '%senior%'
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the patient who has the most recent undergoing treatment?
#
### SQL:
#
# SELECT patient FROM undergoes ORDER BY dateundergoes LIMIT 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Which patient is undergoing the most recent treatment?
#
### SQL:
#
# SELECT patient FROM undergoes ORDER BY dateundergoes LIMIT 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the names of all patients who have an undergoing treatment and are staying in room 111.
#
### SQL:
#
# SELECT DISTINCT T2.name FROM undergoes AS T1 JOIN patient AS T2 ON T1.patient = T2.SSN JOIN stay AS T3 ON T1.Stay = T3.StayID WHERE T3.room = 111
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are the names of patients who are staying in room 111 and have an undergoing treatment?
#
### SQL:
#
# SELECT DISTINCT T2.name FROM undergoes AS T1 JOIN patient AS T2 ON T1.patient = T2.SSN JOIN stay AS T3 ON T1.Stay = T3.StayID WHERE T3.room = 111
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# List the names of all distinct nurses ordered by alphabetical order?
#
### SQL:
#
# SELECT DISTINCT name FROM nurse ORDER BY name
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What is the alphabetically ordered list of all the distinct names of nurses?
#
### SQL:
#
# SELECT DISTINCT name FROM nurse ORDER BY name
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the names of nurses who are nursing an undergoing treatment.
#
### SQL:
#
# SELECT DISTINCT T2.name FROM undergoes AS T1 JOIN nurse AS T2 ON T1.AssistingNurse = T2.EmployeeID
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Which nurses are in charge of patients undergoing treatments?
#
### SQL:
#
# SELECT DISTINCT T2.name FROM undergoes AS T1 JOIN nurse AS T2 ON T1.AssistingNurse = T2.EmployeeID
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# List the names of all distinct medications, ordered in an alphabetical order.
#
### SQL:
#
# SELECT DISTINCT name FROM medication ORDER BY name
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What is the alphabetically ordered list of all distinct medications?
#
### SQL:
#
# SELECT DISTINCT name FROM medication ORDER BY name
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are the names of the physician who prescribed the highest dose?
#
### SQL:
#
# SELECT T1.name FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician ORDER BY T2.dose DESC LIMIT 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the physician who prescribed the highest dose. What is his or her name?
#
### SQL:
#
# SELECT T1.name FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician ORDER BY T2.dose DESC LIMIT 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# List the physicians' employee ids together with their primary affiliation departments' ids.
#
### SQL:
#
# SELECT physician , department FROM affiliated_with WHERE primaryaffiliation = 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are each physician's employee id and department id primarily affiliated.
#
### SQL:
#
# SELECT physician , department FROM affiliated_with WHERE primaryaffiliation = 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# List the names of departments where some physicians are primarily affiliated with.
#
### SQL:
#
# SELECT DISTINCT T2.name FROM affiliated_with AS T1 JOIN department AS T2 ON T1.department = T2.departmentid WHERE PrimaryAffiliation = 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are the names of departments that have primarily affiliated physicians.
#
### SQL:
#
# SELECT DISTINCT T2.name FROM affiliated_with AS T1 JOIN department AS T2 ON T1.department = T2.departmentid WHERE PrimaryAffiliation = 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What nurses are on call with block floor 1 and block code 1? Tell me their names.
#
### SQL:
#
# SELECT nurse FROM on_call WHERE blockfloor = 1 AND blockcode = 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the ids of the nurses who are on call in block floor 1 and block code 1.
#
### SQL:
#
# SELECT nurse FROM on_call WHERE blockfloor = 1 AND blockcode = 1
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are the highest cost, lowest cost and average cost of procedures?
#
### SQL:
#
# SELECT MAX(cost) , MIN(cost) , AVG(cost) FROM procedures
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Tell me the highest, lowest, and average cost of procedures.
#
### SQL:
#
# SELECT MAX(cost) , MIN(cost) , AVG(cost) FROM procedures
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# List the name and cost of all procedures sorted by the cost from the highest to the lowest.
#
### SQL:
#
# SELECT name , cost FROM procedures ORDER BY cost DESC
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Sort the list of names and costs of all procedures in the descending order of cost.
#
### SQL:
#
# SELECT name , cost FROM procedures ORDER BY cost DESC
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the three most expensive procedures.
#
### SQL:
#
# SELECT name FROM procedures ORDER BY cost LIMIT 3
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are the three most costly procedures?
#
### SQL:
#
# SELECT name FROM procedures ORDER BY cost LIMIT 3
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the physicians who are trained in a procedure that costs more than 5000.
#
### SQL:
#
# 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
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Which physicians are trained in procedures that are more expensive than 5000?
#
### SQL:
#
# 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
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the physician who was trained in the most expensive procedure?
#
### SQL:
#
# 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
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Which physician was trained in the procedure that costs the most.
#
### SQL:
#
# 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
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What is the average cost of procedures that physician John Wen was trained in?
#
### SQL:
#
# 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"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Compute the mean price of procedures physician John Wen was trained in.
#
### SQL:
#
# 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"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the names of procedures which physician John Wen was trained in.
#
### SQL:
#
# 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"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are the names of procedures physician John Wen was trained in?
#
### SQL:
#
# 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"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find all procedures which cost more than 1000 or which physician John Wen was trained in.
#
### SQL:
#
# 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"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are the procedures that cost more than 1000 or are specialized in by physician John Wen?
#
### SQL:
#
# 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"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the names of all procedures which cost more than 1000 but which physician John Wen was not trained in?
#
### SQL:
#
# 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"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Among the procedures that cost more than 1000, which were not specialized in by physician John Wen?
#
### SQL:
#
# 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"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the names of all procedures such that the cost is less than 5000 and physician John Wen was trained in.
#
### SQL:
#
# 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"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What procedures cost less than 5000 and have John Wen as a trained physician?
#
### SQL:
#
# 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"
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the name of physicians who are affiliated with both Surgery and Psychiatry departments.
#
### SQL:
#
# 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'
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Which physicians are affiliated with both Surgery and Psychiatry departments? Tell me their names.
#
### SQL:
#
# 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'
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the name of physicians who are affiliated with Surgery or Psychiatry department.
#
### SQL:
#
# 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'
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Which physicians are affiliated with either Surgery or Psychiatry department? Give me their names.
#
### SQL:
#
# 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'
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the names of patients who are not using the medication of Procrastin-X.
#
### SQL:
#
# 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'
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are the names of patients who are not taking the medication of Procrastin-X.
#
### SQL:
#
# 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'
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the number of patients who are not using the medication of Procrastin-X.
#
### SQL:
#
# 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' )
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# How many patients are not using Procrastin-X as medication?
#
### SQL:
#
# 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' )
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# How many appointments are there?
#
### SQL:
#
# SELECT count(*) FROM appointment
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Count how many appointments have been made in total.
#
### SQL:
#
# SELECT count(*) FROM appointment
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# Find the names of nurses who are on call.
#
### SQL:
#
# SELECT DISTINCT T1.name FROM nurse AS T1 JOIN on_call AS T2 ON T1.EmployeeID = T2.nurse
#
### End.
|
hospital_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Physician ( EmployeeID, Name, Position, SSN )
# Department ( DepartmentID, Name, Head )
# Affiliated_With ( Physician, Department, PrimaryAffiliation )
# Procedures ( Code, Name, Cost )
# Trained_In ( Physician, Treatment, CertificationDate, CertificationExpires )
# Patient ( SSN, Name, Address, Phone, InsuranceID, PCP )
# Nurse ( EmployeeID, Name, Position, Registered, SSN )
# Appointment ( AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom )
# Medication ( Code, Name, Brand, Description )
# Prescribes ( Physician, Patient, Medication, Date, Appointment, Dose )
# Block ( BlockFloor, BlockCode )
# Room ( RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable )
# On_Call ( Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd )
# Stay ( StayID, Patient, Room, StayStart, StayEnd )
# Undergoes ( Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse )
#
# Department.Head can be joined with Physician.EmployeeID
# Affiliated_With.Department can be joined with Department.DepartmentID
# Affiliated_With.Physician can be joined with Physician.EmployeeID
# Trained_In.Treatment can be joined with Procedures.Code
# Trained_In.Physician can be joined with Physician.EmployeeID
# Patient.PCP can be joined with Physician.EmployeeID
# Appointment.Physician can be joined with Physician.EmployeeID
# Appointment.PrepNurse can be joined with Nurse.EmployeeID
# Appointment.Patient can be joined with Patient.SSN
# Prescribes.Appointment can be joined with Appointment.AppointmentID
# Prescribes.Medication can be joined with Medication.Code
# Prescribes.Patient can be joined with Patient.SSN
# Prescribes.Physician can be joined with Physician.EmployeeID
# Room.BlockFloor can be joined with Block.BlockFloor
# Room.BlockCode can be joined with Block.BlockCode
# On_Call.BlockFloor can be joined with Block.BlockFloor
# On_Call.BlockCode can be joined with Block.BlockCode
# On_Call.Nurse can be joined with Nurse.EmployeeID
# Stay.Room can be joined with Room.RoomNumber
# Stay.Patient can be joined with Patient.SSN
# Undergoes.AssistingNurse can be joined with Nurse.EmployeeID
# Undergoes.Physician can be joined with Physician.EmployeeID
# Undergoes.Stay can be joined with Stay.StayID
# Undergoes.Procedures can be joined with Procedures.Code
# Undergoes.Patient can be joined with Patient.SSN
#
### Question:
#
# What are the distinct names of nurses on call?
#
### SQL:
#
# SELECT DISTINCT T1.name FROM nurse AS T1 JOIN on_call AS T2 ON T1.EmployeeID = T2.nurse
#
### End.
|
ship_mission
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# mission ( Mission_ID, Ship_ID, Code, Launched_Year, Location, Speed_knots, Fate )
# ship ( Ship_ID, Name, Type, Nationality, Tonnage )
#
# mission.Ship_ID can be joined with ship.Ship_ID
#
### Question:
#
# How many ships are there?
#
### SQL:
#
# SELECT count(*) FROM ship
#
### End.
|
ship_mission
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# mission ( Mission_ID, Ship_ID, Code, Launched_Year, Location, Speed_knots, Fate )
# ship ( Ship_ID, Name, Type, Nationality, Tonnage )
#
# mission.Ship_ID can be joined with ship.Ship_ID
#
### Question:
#
# What is the number of ships?
#
### SQL:
#
# SELECT count(*) FROM ship
#
### End.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.