The relational schema shown below is part of a hospital database. The primary keys are highlighted in bold.
Patient (patientNo, patName, patAddr, DOB)
Ward (wardNo, wardName, wardType, noOfBeds)
Contains (patientNo, wardNo, admissionDate)
Drug (drugNo, drugName, costPerUnit)
Prescribed (patientNo, drugNo, unitsPerDay, startDate, finishDate)
Formulate the following SQL statements:
(1) List all the patients' details, alphabetically by name.
(2) List all the patients contained in the 'Surgical' ward.
(3) List all the patients admitted today.
(4) Find the names of all the patients being prescribed 'Morphine'.
(5) What is the total cost of Morphine supplied to a patient called 'John Smith' ?
(6) What is the maximum, minimum and average number of beds in a ward? Create appropriate column headings for the results table.
(7) For each ward that admitted more than 10 patients today, list the ward number, ward type and number of beds in each ward.
(8) List the numbers and names of all patients and the drugNo and number of units of their medication. The list should also include the details of patients that are not prescribed medication.
Correct Answer:
Verified
FROM Patient
ORDER BY patNam...
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q1: What are the main advantages and disadvantages
Q2: Consider the following relational schema:
Q3: The following tables form part of a
Q4: The following tables form part of a
Q6: A relational database contains details about journeys
Q7: The following tables form part of a
Q8: Write SQL*Plus commands to do the following:
Q9: Assume that the following table is created
Q10: What is a sequence? Write an SQL
Q11: (a) What is a 'table' and what
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents