Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
SQL Queries

SQL Queries

Ratings: (0)|Views: 107 |Likes:
Published by Lauren Johnson
SQL Queries for pharmacy database
SQL Queries for pharmacy database

More info:

Published by: Lauren Johnson on Nov 19, 2012
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less





1. Creates a view of patient info with their first name, last name, date of birth, and phone number in birthday ascending order.drop view if exists v_patient_info;create view v_patient_infoas select pat_fname, pat_lname, pat_DOB, pat_phonefrom patientorder by pat_DOB;select * from v_patient_info;2. Creates a view named prescription log that has their patient id, med id, andprescription date from the prescription tables ordered by prescription date in ascending order by date.drop view if exists v_presciption_log;create view v_prescription_logas select pat_id, med_id, pre_datefrom prescriptionorder by pre_date;select * from v_prescription_log;3. Creates a view called physician directory with columns named name, phone, specialty that has the physicians first name, last name, phone, and specialty grouped by physician specialty.drop view if exists v_physician_directory;create view v_physician_directory (name, phone, specialty)as select concat(phy_fname, " ", phy_lname), phy_phone, phy_specialtyfrom physiciangroup by phy_specialty;select * from v_physician_directory;4. Creates a view called medication price. Has rows id, name, and price with medication id, medication name, and medication price where medication price is lessthan or equal to $30 and ordered by medication id.drop view if exists v_medication_price;create view v_medication_price (id, name, price)as select med_id, med_name, concat('$', format(med_price, 2))from medicationwhere med_price >= 30order by med_id;select * from v_medication_price;5. Creates a view called patient treatment dates with patient treatment id, date, start time and results where patient treatment date contains 2012 and is ordered by patient treatment id.drop view if exists v_patient_treat_dates;create view v_patient_treat_dates asselect ptr_id, ptr_date, ptr_start_time, ptr_resultsfrom patient_treatmentwhere ptr_date like '2012%'order by ptr_id;

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->