赞
踩
转自: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;
(2)使查询结果返回中间的10到100行:
如:
注:select * from OB_CALL_DATA_LOG
再如:
select
b.jgmc
from T_COMMUNITY_SERVICE t
left join T_CORRECT_ARCHIVE a
on a.pk_id=t.A_PK
inner join table(GET_CHILD_DEPT(579)) b
on b.PK_ID = a.DEPT_PK
where
t.DR=0 and b.DR=0 and a.DR=0
and rownum<10 minus
select
b.jgmc
from T_COMMUNITY_SERVICE t
left join T_CORRECT_ARCHIVE a
on a.pk_id=t.A_PK
inner join table(GET_CHILD_DEPT(579)) b
on b.PK_ID = a.DEPT_PK
where t.DR=0 and b.DR=0 and a.DR=0
and rownum>2
;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。