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
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
?
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.