Oracle实现查询前几操作
介绍:由于在SQL Server中查询前几名可以直接是用Select Top 10 * from Table ,而在Oracle数据库中没有Top关键字,所以可以使用Rownum()方法来实现。
语句结构:
select * from (select * from db_stu order by colum2 desc) where rownum <= number order by colum2
实例:对学生表db_stu进行查询分数年级前十的学生信息:
select * from (select * from db_stu order by name desc) where rownum <= 10 order by score
SQL SERVER 实现:
---SQL Server实现 select top 10 * from db_stu order by score