human
Schema:
Physician (EmployeeID, Name, Position, SSN)
Department (DepartmentID, Name, Head)
Affiliated_With (Physician, Department, PrimaryAffiliation)
Procedures (Code, Name, Cost)
Trained_In (Physician, Treatment, CertificationDate, CertificationExpires)
Patient (SSN, Name, Address, Phone, InsuranceID, PCP)
Nurse (EmployeeID, Name, Position, Registered, SSN)
Appointment (AppointmentID, Patient, PrepNurse, Physician, Start, End, ExaminationRoom)
Medication (Code, Name, Brand, Description)
Prescribes (Physician, Patient, Medication, Date, Appointment, Dose)
Block (BlockFloor, BlockCode)
Room (RoomNumber, RoomType, BlockFloor, BlockCode, Unavailable)
On_Call (Nurse, BlockFloor, BlockCode, OnCallStart, OnCallEnd)
Stay (StayID, Patient, Room, StayStart, StayEnd)
Undergoes (Patient, Procedures, Stay, DateUndergoes, Physician, AssistingNurse)
Please answer with SQL.
assistant
Sure, I understand.
human
What was the start date of the most recent appointment?
assistant
SELECT Start FROM Appointment ORDER BY Start asc LIMIT 1;
human
What is the patient associated with the appointment on 2008-04-24 10:00?
assistant
SELECT Patient FROM Appointment WHERE Start = '2008-04-24 10:00';
human
Can you list the patient IDs associated with appointment IDs 93216548 and 86213939?
assistant
SELECT Patient FROM Appointment WHERE AppointmentID = 93216548 OR AppointmentID = 86213939;
human
Can you list the names associated with those patient ID 100000004 and 100000002?
assistant
SELECT DISTINCT ( T1.name ) FROM patient AS T1 JOIN appointment AS T2 ON T1.ssn = T2.patient WHERE T2.patient = 100000004 OR T2.patient = 100000002 ;