Q:

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

0

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

 employeeid |      name       |  position  | registered |    ssn
------------+-----------------+------------+------------+-----------
        101 | Carla Espinosa  | Head Nurse | t          | 111111110
        102 | Laverne Roberts | Nurse      | t          | 222222220
        103 | Paul Flowers    | Nurse      | f          | 333333330 
nurse | blockfloor | blockcode | oncallstart | oncallend
-------+------------+-----------+---------------------+---------------------
   101 |          1 |         1 | 2008-11-04 11:00:00 | 2008-11-04 19:00:00
   101 |          1 |         2 | 2008-11-04 11:00:00 | 2008-11-04 19:00:00
   102 |          1 |         3 | 2008-11-04 11:00:00 | 2008-11-04 19:00:00
   103 |          1 |         1 | 2008-11-04 19:00:00 | 2008-11-05 03:00:00
   103 |          1 |         2 | 2008-11-04 19:00:00 | 2008-11-05 03:00:00
   103 |          1 |         3 | 2008-11-04 19:00:00 | 2008-11-05 03:00:00

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now