Forum

SQL Query Suzy is a...
 
Share:
Notifications
Clear all

SQL Query Suzy is a patient of Dr. Rahim. She has cancelled her next Appointment


Posts: 1
Guest
Topic starter
(@I Yamaly)
New Member
Joined: 4 years ago

Query:

Suzy is a patient of Dr. Rahim. She has canceled her next appointment with Dr. Rahim. Find other patients of Dr. Rahim ( do not include Suzy in the result and show all their details) whose next appointments are after Suzy's appointment so that the hospital may find a replacement.

Instructions

The following relational schema forms part of a hospital database. The primary keys are underlined and foreign keys are in italics.

Tables:

Doctor (docID, docName, dateHired, monthlySalary, area, chargePerAppt, annualBonus)
Patient (patID, patName, dateOfBirth, nextAppDate, lastAppDate, docID)
Billing (patID, balance, due date, phone, address, city, street, postcode, insurance)

 

 

1 Reply
Posts: 18
Guest
(@A Sharma)
Active Member
Joined: 4 years ago

Here is the query to achieve this requirement. 

select p.*
From patient p, doctor d
Where d.docID = p.docID
And p.patName <> 'Suzy'
And d.docName = 'Dr. Rahim'
And p.nextApptDate > ( select nextApptDate from patient
Where patName = 'Suzy');
Reply

Self Learning Video Tutorials - Software Course

Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: