select top 1 * from 表名 where 关键字 not in( select top 行数-1 关键字 from 表名 order by 关键字 ) order by 关键字 行数-1用具体数代替
楼上的刚说你是正解,你就冒泡@n是id 的值,前面的 1 才是要查的行数
create proc sel @n int as select top 1 * from table where [id]>=@n go ---------------------------------[id]是不是表中潜在的行序号? 如果是这样,为何不能直接用select * from table where [id] = @n
select * from (select top xxx * from yourtable) aa where not exists(select 1 from (select top xxx-1 * from yourtable) bb where aa.id=bb.id)
select top 行数-1 关键字 from 表名 order by 关键字
) order by 关键字
行数-1用具体数代替
@n int
as
select top 1 * from table where [id]>=@n
go
---------------------------------[id]是不是表中潜在的行序号?
如果是这样,为何不能直接用select * from table where [id] = @n
from (select top xxx * from yourtable) aa
where not exists(select 1 from (select top xxx-1 * from yourtable) bb where aa.id=bb.id)