Me n My Programming

If Only I Have TIme

Oracle Limit Clause

This is an example that could help you in creating a pagination in Oracle DB:

SELECT col1, col2
FROM
( SELECT a.*, rownum rnum
FROM
( SELECT col1, col2
FROM t
ORDER BY col1 ) a
WHERE rownum <= max_num
)
WHERE rnum >= min_num;

or, a shorter version:

SELECT col1, col2
FROM
( SELECT  col1, col2,
ROW_NUMBER() OVER (ORDER BY col1) AS row_n
FROM t
)
WHERE row_n BETWEEN min_num AND max_num;

Hence, your code just need to pass the max n min value 😀

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on October 13, 2015 by in Uncategorized.

Navigation

%d bloggers like this: