Revenue Per Product Category

Business problem: the business wants to know which product category to invest more stock in, based on which has generated the most revenue so far (using the original orders table).

What data is needed: each product's category and price, and how many of each were ordered. How tables relate: orders → products via product_id. Write a query returning each category and its total revenue (price × quantity, summed), sorted highest revenue first. Verify: manually check one category's total against the raw orders/products data.

query.sql
Loading editor…

Test cases

  • Full result: revenue per category, highest first
  • Returns exactly two categories

Use Run to explore freely against the sample database. Use Submit to grade your query against every test case, including any hidden ones.