Quantcast
Channel: How do I limit the number of rows returned by an Oracle query after ordering? - Stack Overflow
Viewing all articles
Browse latest Browse all 17

Answer by EvilTeach for How do I limit the number of rows returned by an Oracle query after ordering?

$
0
0

(untested) something like this may do the job

WITHbase AS(    select *                   -- get the table    from sometable    order by name              -- in the desired order),twenty AS(    select *                   -- get the first 30 rows    from base    where rownum < 30    order by name              -- in the desired order)select *                       -- then get rows 21 .. 30from twentywhere rownum > 20order by name                  -- in the desired order

There is also the analytic function rank, that you can use to order by.


Viewing all articles
Browse latest Browse all 17

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>