oracle 地市 区县分组,oracle分组写法 - 挣扎在陌生城市ITMAN的个人空间 - OSCHINA - 中文开源技术交流社区...

--1:无ORDER BY排序的写法。(效率最高)

--(经过测试,此方法成本最低,只嵌套一层,速度最快!即使查询的数据量再大,也几乎不受影响,速度依然!)

SELECT *

FROM (Select ROWNUM AS ROWNO, T.*

from k_task T

where Flight_date between to_date('20060501', 'yyyymmdd') and

to_date('20060731', 'yyyymmdd')

AND ROWNUM <= 20) TABLE_ALIAS

WHERE TABLE_ALIAS.ROWNO >= 10;

--2:有ORDER BY排序的写法。(效率最高)

--(经过测试,此方法随着查询范围的扩大,速度也会越来越慢哦!)

SELECT *

FROM (SELECT TT.*, ROWNUM AS ROWNO

FROM (Select t.*

from k_task T

where flight_date between to_date('20060501', 'yyyymmdd') and

to_date('20060531', 'yyyymmdd')

ORDER BY FACT_UP_TIME, flight_no) TT

WHERE ROWNUM <= 20) TABLE_ALIAS

where TABLE_ALIAS.rowno >= 10;

--3:无ORDER BY排序的写法。(建议使用方法1代替)

--(此方法随着查询数据量的扩张,速度会越来越慢哦!)

SELECT *

FROM (Select ROWNUM AS ROWNO, T.*

from k_task T

where Flight_date between to_date('20060501', 'yyyymmdd') and

to_date('20060731', 'yyyymmdd')) TABLE_ALIAS

WHERE TABLE_ALIAS.ROWNO <= 20

AND TABLE_ALIAS.ROWNO >= 10;

--TABLE_ALIAS.ROWNO between 10 and 100;

--4:有ORDER BY排序的写法.(建议使用方法2代替)

--(此方法随着查询范围的扩大,速度会越来越慢哦!)

SELECT *

FROM (SELECT TT.*, ROWNUM AS ROWNO

FROM (Select *

from k_task T

where flight_date between to_date('20060501', 'yyyymmdd') and

to_date('20060531', 'yyyymmdd')

ORDER BY FACT_UP_TIME, flight_no) TT) TABLE_ALIAS

where TABLE_ALIAS.rowno BETWEEN 10 AND 20;

--5另类语法。(有ORDER BY写法)

--(语法风格与传统的SQL语法不同,不方便阅读与理解,为规范与统一标准,不推荐使用。)

With partdata as(

SELECT ROWNUM AS ROWNO, TT.* FROM (Select *

from k_task T

where flight_date between to_date('20060501', 'yyyymmdd') and

to_date('20060531', 'yyyymmdd')

ORDER BY FACT_UP_TIME, flight_no) TT

WHERE ROWNUM <= 20)

Select * from partdata where rowno >= 10;

--6另类语法 。(无ORDER BY写法)

With partdata as(

Select ROWNUM AS ROWNO, T.*

From K_task T

where Flight_date between to_date('20060501', 'yyyymmdd') and

To_date('20060531', 'yyyymmdd')

AND ROWNUM <= 20)

Select * from partdata where Rowno >= 10;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值