Oralce page-query 21 to 40 data records

Source: Internet
Author: User
-- Oracle method 1SELECT * FROM (SELECTA. *, ROWNUMRNFROM (SELECT * FROMss_custinfo) AWHEREROWNUMlt; 40) WHERERNgt;

-- Oracle method 1 SELECT * FROM (select a. *, rownum rn from (SELECT * FROM ss_custinfo) awhere rownum lt; = 40) where rn gt; =

-- Oracle method 1
SELECT * FROM
(
Select a. *, rownum rn from (SELECT * FROM ss_custinfo)
Where rownum <= 40
)
Where rn> = 21;


-- Oracle method 2
SELECT * FROM
(
Select ss. *, rownum rn from ss_custinfo ss
)
WHERE rn <= 40 and rn> = 21;

-- Oracle method 3
SELECT * FROM
(
Select a. *, ROWNUM RN
FROM (SELECT * FROM ss_custinfo)
)
Where rn between 21 AND 40;


-- Sybase
Select * from
(
Select ss. *, row_number () over (order by cust_id desc) as rn
From ss_custinfo ss
) Temp
Where temp. rn <= 40 and temp. rn> = 21;

Select * from
(
SELECT ss. *, row_number () OVER (partition by cust_id order by salary desc) rn
FROM ss_custinfo ss
) Temp
Where temp. rn <= 40 and temp. rn> = 21;

,

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.