w3resource
SQL exercises

SQL exercises on hospital Database: Find the nurses and the block where they are booked for attending the patients on call

SQL hospital Database: Exercise-29 with Solution

29. Write a query in SQL to obtain the nurses and the block where they are booked for attending the patients on call.

Sample table: nurse


Sample table: on_call


Sample Solution:

SELECT n.name AS "Nurse",
       o.blockcode AS "Block"
FROM nurse n
JOIN on_call o ON o.nurse=n.employeeid;

Sample Output:

      Nurse      | Block
-----------------+-------
 Carla Espinosa  |     1
 Carla Espinosa  |     2
 Laverne Roberts |     3
 Paul Flowers    |     1
 Paul Flowers    |     2
 Paul Flowers    |     3
(6 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.

What is the difficulty level of this exercise?



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