select top 5 from table where id not in (select top 3 * from table)

解决方案 »

  1.   

    我这个表里有三个主键分别是 id ,sbnum,pnum 楼上的朋友说的方法 我用过了,不好使的就没人能帮我吗?????????????愁啊?  高手都睡觉了?????/
      

  2.   

    select top 5 * from table where id not in (select top 3 ID from table)
    不好意思,只是把小黑的稍微改了一點
      

  3.   

    select top 5 from [table] where id not in (select top 3 id from [table])
      

  4.   

    select IDENTITY(int, 1,1) AS ID_Num,* into #temp from 表
    select * from #temp where ID_Num between 10 and 20
      

  5.   

    declare @SQLStr varchar(8000)
    set @SQLStr='SELECT Top '+cast(@每页大小 as varchar)+' * FROM 表 WHERE 主键列 NOT IN (SELECT TOP '+cast(@每页大小*@第几页 as varchar)+' 主键列 from 表 )'
    exec(@SQLStr)
      

  6.   

    select top 5 * from table where id not in (select top 3 * from table order by ID) order by ID需要叫 order by ID 的,否则top 就没意思了。