Chapter 4 · Aggregations
02. Total Revenue by Category
Easy10 XPE-Commerce
The product analytics team wants to see total revenue broken down by product category. Revenue for a line item is quantity * unit_price from order_items; link each item to its product's category. Return the category name and total revenue, sorted by revenue descending.
Tables
- PKidINT
- nameTEXT
- descriptionTEXT
- PKidINT
- nameTEXT
- FKcategory_id→ categories.idINT
- priceREAL
- costREAL
- stock_quantityINT
- created_atTIMESTAMP
- PKidINT
- FKorder_id→ orders.idINT
- FKproduct_id→ products.idINT
- quantityINT
- unit_priceREAL
- discountREAL
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.