Forum

SQL Query List name...
 
Notifications
Clear all

SQL Query List names of patients who live in Petaling Jaya, Subang Jaya, Shah Alam and Klang cities


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

Query:

List names of patients who live in Petaling Jaya, Subang Jaya, Shah Alam and Klang cities, names of their doctors and the patients' balances where the due date is on '30-Jun-2020'

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 find Names of patients who live in Petaling Jaya, Subang Jaya, Shah Alam and Klang cities, names of their doctors and the patients' balances where the due date is on '30-Jun-2020'

Select p.patientName
From patient p, billing b
Where p.patID = b.patID
And b.city in ('Petaling Jaya', 'Subang Jaya', 'Shah Alam', 'Klang')
And trunc(b.dueDate) = '30-JUN-2020';
Reply
Share: