SQL Project
This repository contains SQL scripts for creating and managing a pharmacy database. The database includes three tables: dim_members
, dim_drugs
, and fact_prescriptions
. It also demonstrates the usage of primary and foreign keys for data integrity.
member_id
(Primary Key)member_first_name
member_last_name
member_age
drug_ndc
(Primary Key)drug_name
drug_description
prescription_id
(Primary Key)member_id
(Foreign Key referencingdim_members
)drug_ndc
(Foreign Key referencingdim_drugs
)fill_date
copay
insurance_paid
The following SQL queries are included in this repository:
- Displaying tables:
dim_members
,dim_drugs
, andfact_prescriptions
. - Adding primary and foreign keys to the tables.
- Retrieving the number of prescriptions for each drug.
- Counting prescriptions for a specific drug ('Ambien').
- Grouping prescriptions by age group and calculating related statistics.
- Counting unique members and prescriptions for members over 65.
- Selecting the latest prescription for each member and drug.
- Selecting the latest prescription for a specific member (e.g., member_id = 10003).
- Clone the repository:
git clone https://github.com/Hritvik111/Pharmacy-claims.git