22,209
社区成员
发帖
与我相关
我的任务
分享
create table tt (
a int,b int, c varchar(10)
)
insert into tt select 1,1,'aa'
insert into tt select 1,2,'aa'
insert into tt select 1,3,'aa'
insert into tt select 1,4,'aa'
insert into tt select 2,1,'bb'
insert into tt select 2,2,'bb'
insert into tt select 2,3,'bb'
insert into tt select 2,4,'bb'
select distinct a ,b,c from tt a
where b in(select top 3 b from tt where a=a.a)
select * from tb a where weight in(select top 3 weight from tb where a.dcid=dcid order by weight desc)