Sql queries error

why it does’t work

SELECT p.product_name, SUM(price) AS sales_amount
FROM product p
INNER JOIN store s ON s.store_id = p.store_id
INNER JOIN orders o ON o.store_id = s.store_id
ORDER BY sales_amount
LIMIT 20

You’re summing the sales for each product, right? (ie: using an aggregate function)…so, wouldn’t you need a GROUP BY?

2 Likes