Try,查询每种类型的前两条记录Select * From 表 As A Where ID In (Select Top 2 ID From 表 Where 类型=A.类型 Order By ID)
set rowcount 第N条 select * from table where type='你的类型' set rowcount 0
修改--存储类型 select distinct staff_name into #t from B declare @count int set @count =1 while @count<=(select count(*) from #t) begin --输出固定类型的第几条 select top 1 [staff_name] from #t where staff_name not in (select top (@count) * from #t) set @count=@count+1 end --删除用例 drop table #t
写错了,还要修改--存储类型 select distinct staff_name into #t from B declare @count int set @count =1 while @count<=(select count(*) from #t) begin --输出每种类型的第几条 select top 1 * from B where staff_name not in (select top (@count) * from #t) set @count=@count+1 end --删除用例 drop table #t
set rowcount 第N条
select * from table where type='你的类型'
set rowcount 0
select distinct staff_name into #t from B
declare @count int
set @count =1
while @count<=(select count(*) from #t)
begin
--输出固定类型的第几条
select top 1 [staff_name] from #t where staff_name not in (select top (@count) * from #t)
set @count=@count+1
end
--删除用例
drop table #t
select distinct staff_name into #t from B
declare @count int
set @count =1
while @count<=(select count(*) from #t)
begin
--输出每种类型的第几条
select top 1 * from B where staff_name not in (select top (@count) * from #t)
set @count=@count+1
end
--删除用例
drop table #t