Revenue by category

easySQL~10 min · 3 tests · bitshop

Finance wants one number per category: how much money delivered orders brought in.

Revenue for a line item is quantity * unit_price. Only count orders whose status is 'delivered'. Cancelled, returned and still-shipping orders don’t count yet.

Return one row per category with:

column type meaning
category text the product category
revenue decimal total delivered revenue, rounded to 2 decimals

Row order doesn’t matter.

Tables: orders, order_items, products.

Learn the ideaRead the lesson →
solution.sqlDuckDB · bitshop

Press ⌘ ↵ or Run to check the visible tests. Submit runs the hidden ones too. Everything runs in your browser.

⌘ ↵ to run