求SQL語句.
A B C 字段
S1 20 1
S1 10 1
S2 30 1
S3 50 2
要得到查詢的結果是
S1 30 1
S2 30 1
S3 50 2
[解决办法]
select A,sum(B) as B,max(C) as C from 表 group by A
[解决办法]
--直接分组即可
select A,sum(B) as B,C from 表 group by A,C
[解决办法]
select A,sum(B) as B,C from tab group by A,C order by A,C
[解决办法]
select A,sum(B) as B,C from 表 group by A,C
[解决办法]
Select A,sum(B) B,C from 表名
group by A,C
[解决办法]
select a,sum(b) as b ,c from tbl
group by a,c