I need your help, I am a beginner in MySQL, I want to know the following, I add an image that shows a table, I need to know how to get the sum of the values of column A and show the result duplicate times in the column yellow which is called sum_A. I would really appreciate your help. :)
Asked
Active
Viewed 55 times
0
-
Here's a guide how to ask question. https://stackoverflow.com/help/how-to-ask – Eric Sep 30 '20 at 17:14
1 Answers
0
Try this. orders is your main table. Quantity is your sum column.
drop temporary table temp_table;
CREATE TEMPORARY TABLE temp_table select ID,Quantity from orders;
set @totalQuantitty=(select sum(Quantity) from temp_table);
select *,@totalQuantitty from temp_table

ORCAs
- 151
- 2
- 13
-
Thanks @ORCAs This really help to my question, but I did something different but also works I try a SELECT followed by a SET function, but I don't know if it is an efficient way to implement ... SET Sum_A = ( SELECT IF( SUM(A) FROM ... ) ... – Carolina VG Oct 01 '20 at 18:00
-
If it helped to you to solve your problem you should choose the answer as a solution for making my effort valuable. Otherwise next time nobody will effort to solve your problems. – ORCAs Oct 01 '20 at 21:07