sql查询总结ID相同,但不同的值??的.... 我试图计算相同ID的总和......以下是我的表sql查询总和相同的id,但不同的值?
id barter_value
2 50,000
2 1,50,000
3 47,000
3 55,000
3 50,00,000
我想输出像
id barter_value
2 2,00,000
3 51,00,2000
select a.buyer_id,
a.prod_barter_val
from add_to_cart as a
join(select buyer_id,
sum(prod_barter_val) as total
from add_to_cart group by buyer_id) as b
on a.buyer_id = b.buyer_id;
什么是价值150,000? – Jens