关于在SQL中查询第N条记录
declare @n intset @n=5
drop table #temp
select identity(int,1,1) as id,* into #temp from cpkhdm1 ;
select * from #temp where id between @n and @n
上面两条语句可以,但想改成一条语句却出错:
select top 1 [款号],[图片],[myId] from [dqgl2016].[dbo].[cpkhdm1] where [myid] not in (select top @n [myid] from [dqgl2016].[dbo].[cpkhdm1])
好象不能用变量n,改为常数又可以,为什么
select top 1 [款号],[图片],[myId] from [dqgl2016].[dbo].[cpkhdm1] where [myid] not in (select top 5 [myid] from [dqgl2016].[dbo].[cpkhdm1])