Find products priced above category average
SQL
Hard
8 views
Problem Description
Return products where price is greater than average price of their category.
Sample Test Case
Input:
Products(category, price)
Constraints
Correlated subquery
Official Solution
SELECT p.product_id, p.name, p.price FROM Products p WHERE p.price > (SELECT AVG(x.price) FROM Products x WHERE x.category = p.category);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!