Skip to main content
All Problems
medium0% acceptance

Rank Products by Revenue Within Category

For each product, calculate its total revenue from order_items (quantity * unit_price) and rank it within its category using RANK(). Return the category name, product name, total revenue (rounded to 2), and the rank. Order by category name, then rank.

Schema

🔑idINT
nameTEXT
descriptionTEXTNULL
postgresql

Run your query to see results

Press Ctrl + Enter to execute