表记录:
借款 金额
a 100
b 200
a 50
b 30
c 100

搜索求和
得出a 总计 150
b 总计230
c 总计100


求源代码




回复讨论(解决方案)

select 借款,sum(金额) from table group by 借款

好吧,你还是高估了我,

表名:nah
name shuliang danjia zongjia
a 100 0.1 10
b 200 0.2 40
a 50 0.4 20
b 30 0.2 6
c 100 0.8 80

按照name分类汇总
得出a shuliang 150 zongjia 3o
b shuliang 230 zongjia 46
c shuliang 100 zongjia 80

求以上源代码,小白求码

有什么区别吗?
select name, sum(shuliang) as shuliang, sum(zongjia) as zongjia from nah group by name

08-23 04:27