w3resource
SQL exercises

SQL exercises on hospital Database: Find the name of the nurses and the room scheduled, where they will assist the physicians

SQL hospital Database: Exercise-16 with Solution

16. Write a query in SQL to find the name of the nurses and the room scheduled, where they will assist the physicians.

Sample table: nurse


Sample table: appointment


Sample Solution:

SELECT n.name AS "Name of the Nurse",
       a.examinationroom AS "Room No."
FROM nurse n
JOIN appointment a ON a.prepnurse=n.employeeid;

Sample Output:

 Name of the Nurse | Room No.
-------------------+----------
 Carla Espinosa    | A
 Carla Espinosa    | B
 Laverne Roberts   | A
 Paul Flowers      | B
 Paul Flowers      | C
 Laverne Roberts   | A
 Carla Espinosa    | B
(7 rows)

Practice Online


E R Diagram of Hospital Database:

E R Diagram: SQL 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 and the number of the room where they have to go for their treatment.
Next: 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.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming