The product team wants to know which items drive the most revenue. Using the order_items table, return product_id, revenue (sum of amount), and revenue_share_pct (product revenue as a percentage of total revenue, rounded to 2 decimal places), ordered by revenue descending.
order_items
| column | type |
|---|---|
| id | INTEGER |
| order_id | INTEGER |
| product_id | INTEGER |
| amount | NUMERIC |
| id | order_id | product_id | amount |
|---|---|---|---|
| 1 | 1 | 1 | 200.00 |
| 2 | 1 | 2 | 100.00 |
| 3 | 2 | 1 | 400.00 |
| 4 | 2 | 3 | 100.00 |
| 5 | 3 | 2 | 200.00 |
| product_id | revenue | revenue_share_pct |
|---|---|---|
| 1 | 600.00 | 60.00 |
| 2 | 300.00 | 30.00 |
| 3 | 100.00 | 10.00 |
Product 1 earned 200 + 400 = 600 (60% of 1000 total). Product 2 earned 100 + 200 = 300 (30%). Product 3 earned 100 (10%).