Oracle 只获取前10条数据
常见的四种方式:
-- 1.无需排序,简单查询
select * from table_name where rownum <= 10;
-- 2.字段排序,常用做法
select * from (select * from table_name order by STATS_DATE desc) where rownum <= 10;
-- 3.字段排序,不包含相同结果
select q.* from table_name q where q.COMPANY_ID = '813b0d1fe1d13a20' order by q.STATS_DATE desc FETCH FIRST 10 ROWS ONLY;
-- 4.字段排序,包含相同结果
select q.* from table_name q where q.COMPANY_ID = '813b0d1fe1d13a20' order by q.STATS_DATE desc FETCH FIRST 10 PERCENT ROWS WITH TIES