我有一个名为Stud的表,其中我有一个列来存储总数。现在我需要在总列中找到第五大总数。如何执行此操作?
答案 0 :(得分:2)
试试这个:
SELECT total FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY total DESC) as RN, total FROM Stud
) T
WHERE RN=5
答案 1 :(得分:1)
Select total
From
(SELECT total,
row_number() over(order by total desc) as rn
From totalTable
)Z
Where rn=5
也可以使用ROWNUM伪列
来完成Select total
From
(SELECT total
FROM totalTable
ORDER BY total desc
)Z
Where ROWNUM=5