RamHardikar
Programmer
How can I do paging in SQL
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
col a heading "Employee Name" format a20
select rownum,first_name||' '||last_name a from s_emp;
ROWNUM Employee Name
------ --------------------
1 Carmen Velasquez
2 LaDoris Ngao
3 Midori Nagayama
4 Mark Quick-To-See
5 Audry Ropeburn
6 Molly Urguhart
7 Roberta Menchu
8 Ben Biri
9 Antoinette Catchpole
10 Marta Havel
11 Colin Magee
12 Henry Giljum
13 Yasmin Sedeghi
14 Mai Nguyen
15 Andre Dumas
16 Elena Maduro
17 George Smith
18 Akira Nozaki
19 Vikram Patel
20 Chad Newman
21 Alexander Markarian
22 Eddie Chang
23 Radha Patel
24 Bela Dancs
25 Sylvie Schwartz
select rownum, first_name||' '||last_name a
from s_emp
where rownum between 20 and 40;
no rows selected.
accept row_beg prompt "What is the starting row number?: "
accept row_end prompt "What is the ending row number?: "
select rn,first_name||' '||last_name a
from (select rownum rn,first_name,last_name from s_emp)
where rn between &row_beg and &row_end
order by rn;
(I saved the above script to Ram_test.sql)
@Ram_test
What is the starting row number?: 7
What is the ending row number?: 12
RN Employee Name
---------- --------------------
7 Roberta Menchu
8 Ben Biri
9 Antoinette Catchpole
10 Marta Havel
11 Colin Magee
12 Henry Giljum