row_number
が最良のアプローチですが、1行だけが必要なため、必ず計画を確認してください。目的の行を特定してから、元のテーブルに結合して追加の列を取得する方がよい場合があります。
WITH T1
AS (SELECT *,
ROW_NUMBER() OVER (ORDER BY number) AS RN
FROM master..spt_values)
SELECT name,
number,
type,
low,
high,
status
FROM T1
WHERE RN = 1000;
与える
WITH T2
AS (SELECT number,
type,
name,
ROW_NUMBER() OVER (ORDER BY number) AS RN
FROM master..spt_values)
SELECT TOP 1 C.name,
C.number,
C.type,
C.low,
C.high,
C.status
FROM T2
CROSS APPLY (SELECT *
FROM master..spt_values v
WHERE v.number = T2.number
AND v.type = T2.type
AND ( v.name = T2.name
OR ( v.name IS NULL
AND T2.name IS NULL ) )) C
WHERE RN = 1000;
与える