I have a simple question but I can’t find an answer (please give me a link if that question is on stackoverflow forum).
Table has orderid and quantity columns.
How to select orderid, quantity, total_in_order, where total_in_order is a sum of quantity for current orderid
So the table looks the same, but with additional column.
Example:
orderid - quantity - **total_in_order**
1 - 43 - **78**
1 - 24 - **78**
1 - 11 - **78**
2 - 31 - **31**
3 - 9 - **25**
3 - 16 - **25**
So, how to modify SELECT orderid, quantity, SUM(quantity) from orders; ?
Thank you.
Use a join to a subselect. In the subselect calculate the totals for each orderid.