解決Oracle分頁查詢中排序與效率問題

來源:互聯網
上載者:User

原始未分頁查詢Sql代碼如下:

select ROWNUM rn, t.id ID, o.name YYB,u.name XM, t.MC from tZDYSX
t,tuser  u,lborganization o where t.cjr=u.id and u.orgid=o.orgcode and t.gx = 1
order  by ID

結果如下:

RN    ID      YYB       XM     MC
---------- ----------------- ----------------------
3     49  某證券總部     管理員 測試
4     96  某證券總部     管理員 持有上港10000股以上
5    102 某證券總部     管理員 十年規劃
14   105 某證券總部     管理員 開發渠道為上海
11   106 某證券總部     管理員 萬科A
12   107 某證券總部     管理員 11
13   108 某證券總部     管理員 今天過生日的客戶
2    109 某證券總部     管理員 客戶狀態正常
6    110 某證券總部     管理員 無交易
7    111 某證券總部     管理員 OA
8    112 某證券總部     管理員 幸運客戶
9    113 某證券總部     管理員 風險型
10   114 某證券總部     管理員 tst
22   115 白沙網上交易   安昌彪 安客戶正常
1    118 某證券總部     管理員 213
18   119 某證券總部     管理員 客戶號包含1008
17   120 某證券總部     管理員 aaa
19   123 某證券總部     管理員 ssssssss
20   124 某證券總部     管理員 www
21   126 某證券總部     管理員 123123
15   127 某證券總部     管理員 1212
16   128 某證券總部     管理員 aaaaaa

22 rows selected

最初我使用如下Sql代碼查詢:   select * from (select ROWNUM rn, t.id ID, o.name YYB,u.name XM,  t.MC
from tZDYSX t,tuser u,lborganization o where t.cjr=u.id and  u.orgid=o.orgcode and
t.gx = 1 order by t.ID )Where rn>10 and  rn<=20;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.