• Healthcare
  • 4 tables
  • 21,760 rows
  • 7 formats
  • SQL edition
  • synthetic data

Pharmacy Dataset for SQL Practice

This ready-made synthetic dataset is designed for professionals looking to practice SQL queries on pharmacy-related data. It includes detailed information on products, customers, sales transactions, and inventory levels. A free sample is available for preview.

  • last updated 5 Oct 2026
  • by GoMask
  • Dataset covers 4 tables and 21,760 rows.
  • Includes product, customer, sales, and inventory data.
  • Data spans from 2023-01-01 to 2024-12-31.
  • Features 23 columns with detailed information.
  • Supports SQL database practice and query development.
  • Full download available using credits.

At a glance

  • 4tables
  • 21,760rows
  • 23columns
  • Jan 2023 – Dec 2024date range

The 4 tables

preview and data dictionary per table

Products products · table · 3,000 rows

Contains information about pharmaceutical products.

Preview

First 10 of 3,000 rows of the Products table
product_iduuidproduct_namestringcategorystringunit_pricedecimalmanufacturerstring
32f34a49-c967-40a3-8abe-6e6e5b1ea5cdFexofenadine 180mgAllergy19.79PharmaCorp
a0f0ed83-452f-44f7-83ad-bc956bf5f19eMultivitamin DailyVitamins8.71HealthGen
d8432a4f-79ea-46f9-96b6-5db31fd8b892Multivitamin Daily-2Vitamins8.49PharmaCorp
1b237f0c-2eba-4efb-8c39-e9fefe5de53dVitamin C 1000mgVitamins8.83Rx Solutions
f9047d40-38b0-4657-8082-0351595ef365Vitamin D3 2000IUVitamins20.13MediLife
15c71fb0-8c81-4641-ad48-95bfb4b35f2eMultivitamin Daily-3Vitamins18.64PharmaCorp
b433a0d8-dc39-42e7-a9fd-05e03985b603Loratadine 10mgAllergy16.01Rx Solutions
d139506e-c3eb-46c9-b49f-d1d1d2056eacVitamin D3 2000IU-2Vitamins8.57BioPharma
81e07aee-9101-4219-970a-43f44c4eeeb3Ibuprofen 400mgPain Relief5.13MediLife
6e92e8dd-1e78-48d9-bce1-49edf973b037Vitamin C 1000mg-2Vitamins14.58Rx Solutions
10 of 3,000 rows · 5 columns

Data dictionary

Data dictionary for the Products table
columntypedescriptionexamplenull %
product_iduuidUnique identifier for each pharmaceutical product.unique32f34a49-c967-40a3-8abe-6e6e5b1ea5cd0%
product_namestringBrand or generic medication name including formulation or dosage strength.uniqueFexofenadine 180mg0%
categorystringTherapeutic or clinical classification of the product.Allergy0%
unit_pricedecimalStandard retail unit selling price in USD.19.790%
manufacturerstringPharmaceutical manufacturing company.PharmaCorp0%

Customers customers · dimension table · 5,000 rows

Information about pharmacy customers.

Preview

First 10 of 5,000 rows of the Customers table
customer_iduuidfirst_namestringlast_namestringemailstringcitystringstatestringloyalty_program_statusstring
b21e0c06-3661-4c6b-b900-ab200f2790a1OliviaSmith[email protected]RivertownNYBronze
e8176029-77cc-4418-b557-fd40290a0695NoahScott[email protected]SpringfieldILBronze
65896a0f-be22-40b2-9c5d-6c4f16bfce45EmmaSullivan[email protected]SpringfieldILBronze
7bc1dc18-c02a-49dd-aad1-fcc7d928e622LiamStewart[email protected]MaplewoodTXBronze
f0f23f60-c019-4c7b-8b71-7cac02fae1caOliviaSanders[email protected]MaplewoodTXBronze
bcbada17-5df9-46e7-b23b-ef416127f26fMasonSimmons[email protected]SpringfieldILBronze
f265f5fb-30e1-46be-a9b0-7202674fcd20IsabellaStevens[email protected]OakvilleCABronze
a4a6c650-f17a-42b8-af06-714b9f3804cfEthanSpencer[email protected]OakvilleCABronze
97d84c38-114d-44b3-ab2c-9f9d639dafdeAvaStone[email protected]MaplewoodTXBronze
837e35c3-9b95-4020-a0c1-a1d46cf870ffLucasSharp[email protected]SpringfieldILBronze
10 of 5,000 rows · 7 columns

Data dictionary

Data dictionary for the Customers table
columntypedescriptionexamplenull %
customer_iduuidUnique primary key identifier for each customer.uniqueb21e0c06-3661-4c6b-b900-ab200f2790a10%
first_namestringFirst name of the customer or patient.Olivia0%
last_namestringLast name of the customer or patient.Smith0%
emailstringUnique primary email address of the customer.unique[email protected]0%
citystringCity of residence for the customer.Rivertown0%
statestringTwo-letter US postal state abbreviation for the customer's residence.NY0%
loyalty_program_statusstringCustomer membership tier within the pharmacy loyalty rewards program.Bronze0%

Inventory inventory · fact table · 4,481 rows

Tracks product stock levels across different locations.

Preview

First 10 of 4,481 rows of the Inventory table
inventory_iduuidlocationstringquantity_on_handintegerlast_restock_datedateproduct_iduuid
a9908ee8-d9b4-441c-a0ad-f642806d7668Store 1602023-02-01b3090a27-b228-401a-8c0b-924d599fd341
95e97bbf-8fd8-4588-a8e5-b2ec634b56c9Store 2252023-08-108f0f5f8e-f9ab-465b-9a2a-04cb31419ccc
e155b7bc-4fe9-47e4-841f-7163803e79ffStore 2272023-11-1579f43b37-fd6b-48f3-9133-f0abc7c305ea
0d8dd737-8916-4781-b7e4-58bc78d16411Store 1362024-07-039be154f1-261a-4851-8086-6c492e34fca4
dc4a2db1-aecc-4bc4-9712-fc222da0236bStore 1412023-07-0447b1ef24-e568-431e-9dce-082103faa174
9c0cb755-a7bc-4a3b-adbb-a4ff978910daStore 1962023-02-271e0f9ad0-f354-4d52-9cec-f54eb3a47434
8b8081be-ace6-4c65-9372-d75321071501Store 2322024-11-187b81bf3f-f244-4870-8c9b-1043e6fc3125
056dcf02-8b3e-4174-bfd6-a4287d43a05bStore 2322024-07-243f74480a-6817-4d54-b92c-a029cdefc2cf
91d8107e-7794-42d2-ac04-e0cb2a7730cbStore 2902024-04-02776b8c77-0fb9-46b7-82f5-7c14cdf7f704
9068c838-4390-4006-bcc0-926298d64c28Store 1572023-05-084ed4f949-7936-49e3-837f-dd3ebd7f1ef1
10 of 4,481 rows · 5 columns

Data dictionary

Data dictionary for the Inventory table
columntypedescriptionexamplenull %
inventory_iduuidPrimary key uniquely identifying each inventory record.uniquea9908ee8-d9b4-441c-a0ad-f642806d76680%
locationstringPhysical pharmacy branch, counter, or warehouse stocking the product.Store 10%
quantity_on_handintegerCurrent number of units available in stock at the specified location.600%
last_restock_datedateThe date when stock was most recently replenished at this location.2023-02-010%
product_iduuidForeign key to products.product_id.b3090a27-b228-401a-8c0b-924d599fd3410%

Sales sales · fact table · 9,279 rows

Records of individual sales transactions.

Preview

First 2 of 9,279 rows of the Sales table
sale_iduuidsale_datedatequantity_soldintegertotal_revenuedecimalproduct_iduuidcustomer_iduuid
6c50b26c-5fff-4481-8c5f-95cbfa15664d2024-10-08123.132f34a49-c967-40a3-8abe-6e6e5b1ea5cd59efcce9-07c7-4ade-a046-af3b85111d68
ec0ee3da-f2a4-448c-baf1-6b2c8dfe8c4d2023-09-01111.111b237f0c-2eba-4efb-8c39-e9fefe5de53de847dd97-275a-4ad2-8e55-8804560577fb
2 of 9,279 rows · 6 columns

Data dictionary

Data dictionary for the Sales table
columntypedescriptionexamplenull %
sale_iduuidPrimary key unique identifier for the sales transaction.7dbad491-9c0f-4861-be78-4657f8cce19e0%
sale_datedateDate when the transaction occurred between 2023-01-01 and 2024-12-31.2023-09-060%
quantity_soldintegerNumber of units of the product sold in this transaction (1 to 10).10%
total_revenuedecimalCalculated total sale revenue including standard retail markups and quantity.55.940%
product_iduuidForeign key to products.product_id.6dbb3239-5bfa-44d7-9b43-4a75c0233ab40%
customer_iduuidForeign key to customers.customer_id.c45159c4-0d5f-44fe-a4a5-a6cdac8912fc0%

How the tables join

  • sales.product_id references products.product_idmany to one: each Sales row points to one Products row
  • sales.customer_id references customers.customer_idmany to one: each Sales row points to one Customers row
  • inventory.product_id references products.product_idmany to one: each Inventory row points to one Products row

Questions to answer with it

  1. What are the top 5 best-selling products by total revenue, and what is their total quantity sold?

    tables: sales, products

  2. Which products are frequently out of stock (quantity_on_hand = 0)? List their names and current inventory status.

    tables: inventory, products

  3. Calculate the total sales revenue per customer, ordered from highest to lowest.

    tables: sales, customers

  4. What is the average quantity sold per sale for each product category?

    tables: sales, products

Starter SQL

run against this data before publishing

Table names match the SQLite file and the SQL script.

Top 20 Products by Revenue

sql
SELECT p.product_name, SUM(s.total_revenue) AS total_revenue_generated, SUM(s.quantity_sold) AS total_quantity_sold
FROM sales s
JOIN products p ON s.product_id = p.product_id
GROUP BY p.product_name
ORDER BY total_revenue_generated DESC
LIMIT 20;

Total Revenue Per Customer

sql
SELECT c.customer_id, c.first_name, c.last_name, SUM(s.total_revenue) AS customer_total_revenue
FROM sales s
JOIN customers c ON s.customer_id = c.customer_id
GROUP BY c.customer_id, c.first_name, c.last_name
ORDER BY customer_total_revenue DESC
LIMIT 20;

Average Quantity Sold by Category

sql
SELECT p.category, AVG(s.quantity_sold) AS average_quantity
FROM sales s
JOIN products p ON s.product_id = p.product_id
GROUP BY p.category
LIMIT 20;

Customer Loyalty and Sales

sql
SELECT c.loyalty_program_status, COUNT(s.sale_id) AS number_of_sales, SUM(s.total_revenue) AS total_revenue
FROM sales s
JOIN customers c ON s.customer_id = c.customer_id
GROUP BY c.loyalty_program_status
ORDER BY total_revenue DESC
LIMIT 20;

Load it with pandas

python
import pandas as pd

# Unzip the CSV download first: one file per table
products = pd.read_csv("products.csv")
customers = pd.read_csv("customers.csv")
inventory = pd.read_csv("inventory.csv")
sales = pd.read_csv("sales.csv")

# Join sales to products
df = sales.merge(products, left_on="product_id", right_on="product_id", how="left", suffixes=("", "_products"))
print(df.groupby("category").size().sort_values(ascending=False))

Using it in your tool

Excel
Download as XLSX for use in Microsoft Excel.
Power BI
Download as CSV or XLSX for import into Power BI.
SQL
The SQLite download contains the full dataset. For other SQL databases, use the relational SQL dump. Primary keys and foreign keys are defined for join paths.
Python
Download as CSV or JSON for use with Python libraries like Pandas.

Formats available

  • CSV (zip)One CSV file per table, zipped
  • Excel workbookOne worksheet per table
  • SQLite databaseA ready-to-query database file with every table
  • Parquet (zip)One Parquet file per table, zipped
  • SQL scriptCREATE TABLE with primary and foreign keys, then INSERTs
  • CSVA single CSV file
  • JSONA single JSON file

How this data was generated

Synthetic data. Every row was generated: no real people, customers or companies are in this dataset.

Synthetic data generated by GoMask DataFactory from a relational blueprint: keys, links and rules are enforced in code, text columns are filled by a language model. No real people, companies or transactions.

  • Data was generated using GoMask DataFactory.
  • Synthetic transactions mimic typical pharmacy sales patterns.
  • Product categories and customer demographics are proportionally represented.
  • Checked by an automated quality gate: unique keys, no orphan foreign keys, required columns filled, declared rules and date ranges (realism score 100).

Limitations

  • The dataset is synthetic and does not represent real individuals or transactions.
  • Specific drug interactions or detailed medical histories are not included.
  • Inventory restock dates are simplified and do not reflect real-time stock movements.
  • Distributions and correlations are modelled, not measured from real records.

blueprint · pharmacy-dataset-for-sql

Scale this dataset

Same tables. As many rows as you need.

Open the blueprint behind these 4 tables in Data Factory: keep the relationships, change a column, and generate it at the size you need.

  • 200,000 rows
  • 1,000,000 rows
Scale this dataset in Data Factory
Tables
products, customers, inventory, sales
Licence
yours to use, including commercially
API slug
pharmacy-dataset-for-sql

What should your data show?

Preview 20 rows free
No signup. No card.