SELECT doesntmatterwhat
FROM whatever
OFFSET 3 LIMIT 2
我如何重现这一点,但没有使用LIMIT
或OFFSET
来选择最后3行而是最后一行
答案 0 :(得分:1)
SELECT TOP 2 FROM (
SELECT TOP 3 doesntmatterwhat
FROM whatever
) a
ORDER BY doesntmatterwhat
不使用TOP
SELECT n.doesntmatterwhat
FROM (SELECT n.doesntmatterwhat, row_number() OVER (ORDER BY date DESC) AS sequence
FROM whatever n
) n
WHERE n.sequence>= 2 AND n.sequence<= 3;
答案 1 :(得分:1)
这是我正在寻找的解决方案。谢谢你的帮助。
SELECT doesntmatterwhat
FROM whatever
ORDER BY 1
OFFSET 3 ROWS
FETCH FIRST 2 ROWS ONLY;