Forum

SQL Query The Hospi...
 
Notifications
Clear all

SQL Query The Hospital has found a Replacement, a Patient named Hetty.


I Yamaly
Posts: 1
 I Yamaly
Topic starter
(@I Yamaly)
Joined: 1 year ago

Query:

The hospital has found a replacement, a patient named Hetty. Change the appointment date of Hetty to that of Suzy's appointment date.

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
A Sharma
Posts: 18
 A Sharma
(@A Sharma)
Joined: 1 year ago

Here is the query to achieve the expected results.

Update Patient
Set nextApptDate = decode(patName, 'Suzy',
(Select nextApptDate from patient where patName = 'Hetty'),
'Hetty',
(Select nextApptDate from patient where patName = 'Suzy'))

Where patName in ('Suzy', 'Hetty');

 

Reply
Share: