Medium
Description
A line's revenue is quantity × unit_price (ignore discount_pct here). For each category that
has order lines, show:
category_name
revenue: the total revenue of its lines
pct_of_total: its revenue as a percentage of the revenue of all order lines, rounded to 1
decimal place
End your query with ORDER BY revenue DESC, category_name.
Tables
| order_items |
|---|
| item_id (PK) |
| order_id (FK) |
| product_id (FK) |
| quantity |
| unit_price |
| discount_pct |
| products |
|---|
| product_id (PK) |
| category_id (FK) |
| categories |
|---|
| category_id (PK) |
| category_name |