Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Most Prescribed Drug Each Month

For each month (YYYY-MM) return the drug(s) with the largest total quantity prescribed that month. Include all drugs tied for first. Order by month, then drug name.

Table schema

Drugs(drug_id INT PRIMARY KEY, name VARCHAR(30), price INT)
Prescriptions(rx_id INT PRIMARY KEY, patient_id INT, drug_id INT, qty INT, rx_date DATE)

Sample data

Drugs
drug_id | name | price
1 | Paracetamol | 5
2 | Amoxicillin | 20
3 | Insulin | 50
4 | Aspirin | 4

Prescriptions
rx_id | patient_id | drug_id | qty | rx_date
1 | 1 | 1 | 10 | 2026-01-05
2 | 1 | 2 | 2 | 2026-01-20
3 | 2 | 3 | 1 | 2026-01-12
4 | 2 | 1 | 6 | 2026-02-03
5 | 1 | 1 | 4 | 2026-02-10
6 | 3 | 3 | 2 | 2026-02-14

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.