现在表中主要要用的两个字段是:customerid,toatlqty,而且同一customerid,有多个tatalqty,现在要把相同的customerid下的所有toatlqty加起来,即如下实例:
现在的表:
customerid toatlqty
1 30
2 40
5 100
2 20
5 70
统计的结果如下:
customerid toatlqty
1 30
2 60
5 170
这样的SQL语句怎么写啊?
现在的表:
customerid toatlqty
1 30
2 40
5 100
2 20
5 70
统计的结果如下:
customerid toatlqty
1 30
2 60
5 170
这样的SQL语句怎么写啊?
select customerid,sum(toatlqty) ss from tt group by customerid;
SUM(TOATLQTY)
FROM TABLE_NAME
GROUP BY CUSTOMERID;