我有一个 sql 表:
C1 | C2 | C3
aa | bb | 21
gg | hh | 53
dd | yy | 37
我想要 C3 中价值最高的前 5000 行,但我希望我的数据按 C1 排序我该怎么做?谢谢。
使用解析ROW_NUMBER
函数:
SELECT C1, C2, C3
FROM (
SELECT C1, C2, C3, ROW_NUMBER() OVER (ORDER BY C3 DESC) AS C3Rank
FROM myTable
)
WHERE C3Rank <= 500
ORDER BY C1