转载于http://blog.sina.com.cn/s/blog_67e2758d0100s3oc.html

oracle数据库不支持mysql中limit功能,但可以通过rownum来限制返回的结果集的行数,rownum并不是用户添加的字段,而是oracle系统自动添加的。

(1)使查询结果最多返回前10行:

select * from OB_CALL_DATA_LOG where rownum<=10;  (亲测ok)

select * from (select ncallernm, count(*) tol from tmp_86 group by ncallernm order by tol desc) where rownum<20

上面语句不用子查询怎么写??

 

(2)使查询结果返回中间的10到100行:

如:select * from OB_CALL_DATA_LOG rownum<101  minus  select * from OB_CALL_DATA_LOG rownum>9

注:select * from OB_CALL_DATA_LOG    and rownum>99 and rownum<101是错误的,oracle会认为条件不成立

相关文章:

  • 2021-11-20
  • 2021-11-04
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2021-06-10
  • 2022-12-23
  • 2022-02-21
猜你喜欢
  • 2021-08-05
  • 2021-05-22
  • 2022-12-23
  • 2022-01-01
  • 2022-02-03
  • 2022-12-23
  • 2021-08-02
相关资源
相似解决方案