Back to questions

SQL CEIL Practice Exercise SQL Interview Question

SQL CEIL Practice Exercise

SQL Interview Question

Imagine you are a Data Analyst working at CVS Pharmacy, and you had access to pharmacy sales data.

For all Merck drugs, output the drug name, and the unit cost for each drug, rounded up to the nearest dollar. Order it from cheapest to most expensive drug.

Hint: Unit cost is defined as the total sales divided by the units sold.

Table:

Column NameType
product_idinteger
units_soldinteger
total_salesdecimal
cogsdecimal
manufacturervarchar
drugvarchar

Sample Input:

product_idunits_soldtotal_salescogsmanufacturerdrug
937410293452.54208876.01Eli LillyZyprexa
3494698600997.19521182.16AstraZenecaSurmontil
6177023500101.61419174.97BiogenVaricose Relief
13614481410842581006447.73BiogenBurkhart
...................

Example Output:

drugunit_cost
FLU KIDS RELIEF11
DHEA14
METHOCARBAMOL18
Keytruda58
Divalproex sodium100

Difficulty

Easy

Input

Output