Question: write the appropriate SQL commands, resulting the appropriate output for each query: this is our Database: patient(ID(PK),Name,Address,Age,Doctor_ID(FK)) Doctor(ID(PK),Name, Specialization,YearsofService) Drug(Name(PK), Formula,Doctor_ID(FK),Distributer(FK)) PatientDrug(Patient_ID(PK),Drug_Name(PK)) PatientDoctorPrescription(Patient_ID(PK),Doctor_ID(PK),Date,Amount) Pharmacy(Name(PK),Address,Phone_no) PharmacyDrug(Drug_Name(PK),Pharmacy_Name(PK),Price)
write the appropriate SQL commands, resulting the appropriate output for each query:
this is our Database:
patient(ID(PK),Name,Address,Age,Doctor_ID(FK)) Doctor(ID(PK),Name, Specialization,YearsofService) Drug(Name(PK), Formula,Doctor_ID(FK),Distributer(FK)) PatientDrug(Patient_ID(PK),Drug_Name(PK)) PatientDoctorPrescription(Patient_ID(PK),Doctor_ID(PK),Date,Amount) Pharmacy(Name(PK),Address,Phone_no) PharmacyDrug(Drug_Name(PK),Pharmacy_Name(PK),Price) Pharmaceutical_Company(Name(PK),Phone_No) Pharmaceutical_Company_Pharmacy(Pharmaceutical_Company_Name(PK),Pharmacy_Name(PK),Start_Date,End_date,Contract_Text)
here are 6 queries, i want the SQL commands for:
1.total number of Drugs by the name A prescribed by the Doctor B for patients older than 40 years old.
2.average age of patients that have been prescribed drugs made by the pharmaceutical company named A.
3.list of all the drugs cheaper than $1000 that have not been prescribed for any patients yet.
4.name of all the doctors that have prescribed prescriptions in the past month which had a total drug worth of over $10,000.
5.the name of each pharmaceutical company and the number of contracts they've ever had.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
