Hi first time posting here,
Im new to Oracle and sql statements and kind of confused
I was wondering if someone can check whether or not if my SQL queries are correct, I can do simple queries but I seem to have problems with join statements
a. Find the names of all the patients being prescribed ‘Morphine’.
SELECT Prescribed.patientNo, Prescribed.drugNo, Patient.patName, Drug.drugName
FROM Prescribed, Patient, Drug
WHERE Prescribed.patientNo = Patient.patientNo, Prescribed.drugno = Drug.drugNo
AND drugName LIKE 'Morphine';
b. What is the total cost of Morphine supplied to a patient called ‘John Smith’?
WHERE drugName LIKE ‘Morphine’
(SELECT patName FROM Patient
WHERE patName LIKE ‘John Smith’);
c. For each ward that admitted more than 10- patients today, list the ward number, ward type and number of beds in each ward.
SELECT wardNo, wardType, NoOfBeds, patientNo,admissionDate
WHERE COUNT (wardNo) AS COUNT
AND admissionDate = CURRENT_DATE
FROM Ward w, Patient p, Contains c
HAVING COUNT (patientNo) > 10;
d. 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.
SELECT patientNo, patName, drugNo, unitsPerDay
FROM Patient, Prescribed
WHERE Patient.patientNo = Prescribed.patientNo;