34,593
社区成员
发帖
与我相关
我的任务
分享
declare @tb table(A int, B int)
insert into @tb
select 1,2
union all
select 1,4
union all
select 3,5
union all
select 2,8
union all
select 3,2
select A ,B=sum(B) from @tb group by A order by B
/*
A B
----------- -----------
1 6
3 7
2 8
(3 row(s) affected)
*/