34,590
社区成员
发帖
与我相关
我的任务
分享
declare @t table (id int,test int)
insert into @t select 1,1
insert into @t select 3,3
insert into @t select 4,3
insert into @t select 2,2
insert into @t select 5,3
insert into @t select 6,3
insert into @t select 7,3
select * from @t a where id=(select top 1 id from @t where test=a.test and test =3 order by newid())
create table t(id int,test int)
insert into t select 1,1
insert into t select 3,3
insert into t select 4,3
insert into t select 2,2
insert into t select 5,3
insert into t select 6,3
insert into t select 7,3
select * from t a where id=(select top 1 id from t where test=a.test and test =3 order by newid())