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