w3resource
SQL exercises

SQL exercises on hospital Database: Count the number of unavailable rooms

SQL hospital Database: Exercise-7 with Solution

7. Write a query in SQL to count the number of unavailable rooms.

Sample table: room


Sample Solution:

SELECT count(*) "Number of available rooms"
FROM room
WHERE unavailable='true';

Sample Output:

 Number of available rooms
---------------------------
                         7
(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 count the number available rooms.
Next: Write a query in SQL to obtain the name of the physician and the departments they are affiliated with.

What is the difficulty level of this exercise?



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