Find the top 3 products by total revenue in each category. Revenue is calculated from order_items (quantity * unit_price - discount). Use DENSE_RANK to rank and filter to rank <= 3. Show category_id, product name, total revenue, and rank. Sort by category_id, then rank.
Schema
🔑idINT
nameTEXT
🔗category_idINT
priceREAL
costREAL
stock_quantityINT
created_atTIMESTAMP
postgresql
Run your query to see results
Press Ctrl + Enter to execute