Using rownum to implement real Paging

Source: Internet
Author: User

Because rownum of Oracle is a pseudo column, if it is used, it must be queried to display the mark, for example, marked as num in this SQL statement.

It is worth mentioning that the inmost query SQL: "SELECT. group specification code... "itself has a rownum, and then rename the query statement result with the rownum as num column as the table temptable. At this time, the table temptable also has a new rownum.

I marked the new rownum as num, and then I can query any data row I want to use.

Not to mention directly accessing SQL:

Select TB. * from
(
Select rownum as num, temptable. * from
(
Select rownum as RN,. group specification code: bianma,. ID,. IPaddress portipaddress,. maskaddress,. lastoperstatus,. laststatustime,. description,. portnum,
A.ifspeed,a.tar get_id,. ifname,. portdesc,. isfree, B. name devicename, B. node_id, D. name as divecetype, B. IPaddress, B. deep,. ifindex
From smartidc.tar getsport
Left join smartidc.tar gets B on a.tar get_id = B. ID
Left join smartidc. B _nodes C on B. node_id = C. nodeid
Left join smartidc. d_configtree D on B. configtree_id = D. id where 1 = 1
Order by B. Name, A. portnum, A. isfree DESC
)
Temptable
) TB
Where num> 10 and num <= 20;

Using rownum to implement real Paging

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.