View for category revenue
SQL
Hard
0 views
Problem Description
Create view v_category_revenue that returns category and revenue using OrderItems and Products.
Output Format
View created
Sample Test Case
Input:
OrderItems, Products
Constraints
Revenue = qty*price
Official Solution
CREATE VIEW v_category_revenue AS SELECT p.category, SUM(oi.qty * oi.price) AS revenue FROM OrderItems oi JOIN Products p ON p.product_id = oi.product_id GROUP BY p.category;
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!