mysql - sql 不用group by 怎么求和
怪我咯
怪我咯 2017-04-17 13:16:11
0
2
902

对uid 相同的记录的money 求和

比如uid 387 的记录 结果
uid 金额 求和的金额
387 2000.00 5000.00
387 3000.00 5000.00

因为我需要记录的明细 所有不能用group by

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(2)
伊谢尔伦

I know that SQL syntax is very powerful, but I am not very proficient in it. To meet your needs, I provide the following reference opinions.

select a.uid,a.money,c.total_money from (select b.uid,sum(b.money) as total_money from leshi_deal_invest as b group by b.uid) as c 
right join leshi_deal_invest as a 
on a.uid = c.uid;
洪涛
select b.uid, b.money, a.total from (select uid, sum(money) as total from test group by uid) as a, test as b where a.uid = b.uid

Too lazy

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template