--测试数据
create table [tb_a] ([c_a] [int] null,[c_b] [int] null)
go
insert into tb_a
select 1,3 union
select 1,2 union
select 2,4 union
select 2,7 union
select 3,9
--查询
select top 1 c_a, sum(c_b)
from tb_a
group by c_a
order by sum(c_b) desc
--清除
drop table tb_a
create table [tb_a] (
[c_a] [int] null,
[c_b] [int] null
)
go
insert into tb_a
select 1,3 union
select 4,2 union
select 8,4 union
select 7,7 union
select 3,9
select * from tb_a
select c_a from tb_a where c_b=(select max(c_b) from tb_a)
select a.c_a from tb_a a where not exists(select 1 from tb_a where c_b>a.c_b)