SQL exercises on hospital Database: Find the name of patients and their physicians who does not require any assistance of a nurse
SQL hospital Database: Exercise-18 with Solution
18. Write a query in SQL to find the name of patients and their physicians who does not require any assistance of a nurse.
Sample table: patient
Sample table: appointment
Sample table: physician
SELECT t.name AS "Name of the patient", p.name AS "Name of the physician", a.examinationroom AS "Room No." FROM patient t JOIN appointment a ON a.patient=t.ssn JOIN physician p ON a.physician=p.employeeid WHERE a.prepnurse IS NULL;
Name of the patient | Name of the physician | Room No. ---------------------+-----------------------+---------- John Smith | Christopher Turk | C Dennis Doe | Percival Cox | C (2 rows)
E R Diagram of Hospital Database:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a query in SQL to find the name of the patients who taken the appointment on the 25th of April at 10 am, and also display their physician, assisting nurses and room no.
Next: Write a query in SQL to find the name of the patients, their treating physicians and medication.
What is the difficulty level of this exercise?