w3resource
SQL exercises

SQL exercises on hospital Database: Count number of unique patients who got an appointment for examination room C

SQL hospital Database: Exercise-14 with Solution

14. Write a query in SQL to count number of unique patients who got an appointment for examination room C.

Sample table: appointment


Sample Solution:

SELECT count(DISTINCT patient) AS "No. of patients got appointment for room C"
FROM appointment
WHERE examinationroom='C';

Sample Output:

No. of patients got appointment for room C 
--------------------------------------------
                                          3
(1 row)

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 obtain the name of the patients with their physicians by whom they got their preliminary treatement.
Next: 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.

What is the difficulty level of this exercise?



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