SQL Queries for Tables: Patient, Doctor and Appointment

Consider the following relational database:

  • Patient(PID, Pname, Paddress, Pgender, disease)
  • Doctor(DID, Dname, Daddress, Department, salary)
  • Appointment(PID, DID, time)

 

Write SQL syntax for the following:

  1. Display name and address of patients who are suffering from Tuberculosis(TB).
  2. Count the number of doctors working in ENT department.
  3. Display name of doctor who is receiving maximum salary.

a. Display name and address of patients who are suffering from Tuberculosis(TB).


SELECT Pname,
       Paddress
FROM   Patient
WHERE  disease = 'Tuberculosis(TB)';  

 

b. Count the number of doctors working in ENT department.


SELECT COUNT(DID)
FROM   Doctor
WHERE  Department = 'ENT';

 

c. Display name of doctor who is receiving maximum salary.

 SELECT Dname
FROM   Doctor
WHERE  salary = (SELECT MAX(salary)
                 FROM   Doctor);  

 

Asked in Year
2019
Course
BBM
University
TU