Top 3 products per category
For each category, find the top 3 products by revenue from completed orders.
- revenue is the sum of
quantity * unit_price - products that tie on revenue share a rank. Include every product whose rank is 3 or better, so a category can return more than 3 products. For example revenues 500, 300, 300, 200 give ranks 1, 2, 2, 4, so the first three come back and 200 doesn't.
- products with no completed sales aren't ranked at all
output columns
categoryproduct_namerevenueuses , ,
ctrl + enter to run on the sample data · ctrl + shift + enter to submit
run your query to see the output here. Submit checks it against the sample data, hidden test cases, random data and a large dataset.