Question: Write SQL queries in Mysql to perform the following operations. In each case show the SQL statement you used and the output from MySQL. The
Write SQL queries in Mysql to perform the following operations. In each case show the SQL statement you used and the output from MySQL.
The tables of Hospital database are as follows:
team (team_code, telephone_no, staff_no)
consists_of (staff_no, team_code)
doctor (staff_no, doctor_name, position)
specialist (staff_no, specialism)
patient (patient_id, patient_name, gender, height, weight, staff_no, ward_no)
ward (ward_no, ward_name, number_of_beds)
nurse (staff_no, nurse_name, ward_no)
supervises (staff_no, supervisor)
treatment (staff_no, patient_id, start_date, reason)
prescription (prescription_no, quantity, daily_dosage, staff_no, patient_id, start_date, drug_code)
small_occupied_by(patirnt_id, ward_no)
drug (drug_code, drug_name, type, price)
a) List prescription numbers and drugs whose codes are either P51 or X01 in these prescriptions.
b) Find the team codes along with staff numbers in each team.
c) Retrieve the staff numbers, patient identifiers and names along with starting date of all treatments that were between 2007-01-01 and 2007-02-01.
d) List the ward numbers and names along with patient identifiers and the number of patients in each ward. The output table should be sorted based on ward numbers in an ascending way.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
