Reputation: 27
product | quantity | price |
---|---|---|
milk | 3 | 10 |
bread | 7 | 3 |
bread | 5 | 2 |
And my output table should be
product | total_price |
---|---|
milk | 30 |
bread | 31 |
I can't seem to get my code to work. Here is my code
SELECT product, (SELECT (quantity*unit_price)
FROM shopping_history AS sh ) AS total_price
FROM shopping_history
GROUP BY product
Upvotes: 0
Views: 780