比如我指定记录号是5
怎样直接查询到第5条记录啊?

解决方案 »

  1.   

    declare @t table([name] varchar(10))
    insert into @t select 'aa'
    insert into @t select 'bb'
    insert into @t select 'cc'
    insert into @t select 'dd'
    insert into @t select 'teqeq'select [id]=identity(int,1,1),* into # from @t
    select [name] from # where id=5
    drop table #select [name] from (select *,id=(select count(1) from @t where [name]<=a.[name]) from @t a)b where b.id=5
      

  2.   

    select [name] from (select *,id=(select count(1) from @t where [name]<=a.[name]) from @t a)b where b.id=5
    这个写错了