我有一张这样的表:
Count Product
100 apple
50 apple
20 orange
如何选择获得每件产品的总和?
Count Product
150 apple
20 orange
答案 0 :(得分:0)
使用SUM(),
尝试查询 select SUM(count) as count,Product from #YourTable
group by Product
SUM()函数返回数字列的总和
答案 1 :(得分:0)
您应该使用聚合函数:
select SUM(count) as Count, Product from Product
group by Product