Resolving sorting and efficiency issues in Oracle paging queries

Source: Internet
Author: User

The original paging query SQL code is as follows:

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

The results are as follows:

RN ID yyb XM MC
-------------------------------------------------
3 49 a securities headquarters    Administrator Test
4 96 A Securities headquarters administrator holds 10000 shares above
5 102 A security headquarters Manager ten-Year Plan
14 105 A Securities headquarters manager development channel for Shanghai
11 106 a certain security headquarters, Vanke a
12 107 a security headquarters manager one
13 108 A security headquarters administrator for the birthday of today's client
2 109 A Securities headquarters administrator customer status Normal
6 110 A security headquarters administrator without a transaction
7 111 A Security headquarters administrator OA
8 112 A security headquarters manager Lucky Customer
9 113 A security headquarters administrator     Risk Type
10 114 A Security headquarters administrator TST
22 115 White Sands Online trading An Changbio ann Customer Normal
1 118 A Security headquarters Administrator 213
18 119 a securities headquarters The Administrator customer number contains 1008
17 120 A Securities headquarters manager AAA
19 123 A Securities headquarters administrator Ssssssss
20 124 A Security headquarters Administrator www
21 1 26 A security headquarters administrator 123123
15 127 A security headquarters administrator 1212
16 128 A Security headquarters administrator aaaaaa

rows selected

Initially I used the following SQL code query: 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;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.