Say if I have a table with the following column,
假如我有一个包含以下列的表,
Marks
60
80
70
90
95
90
70
I need to select all the rows with a mark in the top 4, ie. in this case, >=70 and 6 rows should be returned.
我需要选择前4位带有标记的所有行,即。在这种情况下,> = 70并且应该返回6行。
I'm not sure how to do this, can someone help please? Thanks.
我不知道怎么做,有人可以帮忙吗?谢谢。
1 个解决方案
#1
3
SELECT Marks FROM (
SELECT Marks, DENSE_RANK() OVER (ORDER BY Marks DESC) AS MarksRank
FROM yourtable
) WHERE MarksRank <= 4
#1
3
SELECT Marks FROM (
SELECT Marks, DENSE_RANK() OVER (ORDER BY Marks DESC) AS MarksRank
FROM yourtable
) WHERE MarksRank <= 4