我有以下查询:
select top 100 eid, cid, id, position, ROW_NUMBER() over(order by eid, cid, id) as record
from standings
where record = 2
这会产生无效的列错误。
如何只检索特定的记录号。我需要这样做,一次一个地迭代结果,以便使用没有身份主键(或一般主键)的表进行数据转换
答案 0 :(得分:4)
你可以从CTE拉出来
;with T as (
select top 100 eid, cid, id, position, ROW_NUMBER() over(order by eid, cid, id) as record
from standings
)
select * from T where record = 2