本文介绍了sql查询相同值的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
id |数量奖金|价格|总计
01 | 25 | 10 | 123 | 4305
01 | 5 | 10 | 123 | 1845
我想要它AS
id |数量奖金|价格|总计
01 | 30 | 10 | 123 | 6150
id | quantity | Bonus | price | total
01 | 25 | 10 | 123 | 4305
01 | 5 | 10 | 123 | 1845
i want IT AS
id | quantity | Bonus | price | total
01 | 30 | 10 | 123 | 6150
推荐答案
select id, sum(quantity). Bonus, Price, sum(total)
from table
group by id, Bonus, price
但这对我来说没有意义!
But it doesn''t make sense to me!
select id,sum(quantity) as quantity,Bonus , price,sum(total)as total
from table group by id,Bonus , price
谢谢
这篇关于sql查询相同值的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!