Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们不能TOP在 ORACLE 中使用 SQL 中的命令来获取前 n 个已排序的行,因为它不支持它。但是有一些方法可以使用rank()and获取结果,rownum()但这需要内部查询。rownum()我想知道除了使用/rank()和内部查询之外是否还有其他方法。
TOP
rank()
rownum()
我不知道“rownum()”是什么。最好的方法是@PinnyM 删除的答案。. .
select * from (<your query here> order by <your ordering> ) t where rownum < xx
这比使用or好得多,因为需要对值进行最少的处理。row_number()rank()rownum
row_number()
rownum
顺便说一句,TOP是特定于 SQL Server 和 Sybase。其他数据库使用LIMIT.
LIMIT