Top 3 Most Profitable Drugs
Problem
**[Asked at CVS Health]**
A pharmacy chain tracks sales data for every drug it sells. Each drug has a total
revenue (`total_sales`) and a total cost (`cogs` — cost of goods sold).
Profit = `total_sales − cogs`
Find the **3 most profitable drugs**. Return `drug_name` and `total_profit`,
ordered from highest to lowest profit.
Tables
Example rows — the live problem includes the full dataset.
drug_sales
| product_id | drug_name | manufacturer | units_sold | total_sales | cogs |
|---|
Expected output
Your answer should return 3 rows with the columns drug_name, total_profit.
Starter code (SQL)
SELECT *
FROM drug_sales;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock