问题描述
我需要您的帮助,我是MysqL的初学者,我想知道以下内容,我添加了一个显示表的图像,我需要知道如何获取A列的值之和并显示结果黄色列中的重复时间称为sum_A。我将衷心感谢您的帮助。 :)
解决方法
尝试一下。订单是您的主要餐桌。数量是您的总和列。
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