Question:
Question For this assignment, use the following database schema:
1) Patient-PatientID, Name, DOB
2) Doctor-DoctorID, Name, MedLicenseNumber, Phone
3) Medication-MedicationID, BrandName, GenericName
4) Prescription-PrescriptionID, Date, PatientID, PrescriberID, MedicationID
Specify the SQL queries to retrieve:
1) A list of all doctors.
2) The number of patients that were born before 01/01/1994.
3) The patient information along with the ID of any prescribing doctor for each patient.
4) The prescription information along with patient name, DOB, medication brand name, and prescribing doctor name sorted by most recent date.
5) The most prescribed generic medication name.
For this assignment, use the following database schema:
1) Patient-PatientID, Name, DOB
2) Doctor-DoctorID, Name, MedLicenseNumber, Phone
3) Medication-MedicationID, BrandName, GenericName
4) Prescription-PrescriptionID, Date, PatientID, PrescriberID, MedicationID
1. select p.patient_id, p.patient_name , p.Date_Of_Birth, d.doctor_id from patient p, doctor D,prescription pr where p.patient_id = pr.patient_id , d.doctor_id = pr.prescriber_id;
2. select pr.prescription_id, pr.date, pr.patient_id, pr.prescriber_id,pr.medication_id, p.patient_name , p.Date_Of_Birth, m.brand_name,d.doctor_name from patient p, doctor D,prescription pr,medication m where p.patient_id = pr.patient_id , d.doctor_id = pr.prescriber_id,pr.medication_id = m.medication_id order by pr.date desc;
3. select m.generic_name from medication m , prescription pr where pr.medication_id = m.medication_id and pr.medication_id = (select medication_id from prescription groupby medication_id having count(1) = (select max(y.num) from (select count(1) as num from prescription groupby medication_id ) y);