SQL to limit number of Rows returned for Oracle SQL Developer

SQL Syntax for Oracle SQL.  How to limit number of rows returned and where to position that syntax.
kdschoolAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
If you want Oracle solutions, it is best to add the Oracle Topic Area.  That is where most Oracle Experts hang out.

There are a few ways based on exactly what you are asking.  The more information about what you are trying to do, the more accurate our advice.

There is rownum but it isn't affected by order and you can only use '<' or '<=' values.  You can't paginate with it easily.
select * from some_table where rownum<11;

You can use inline views to order:
select * from (select * from some_table order by some_column) where rownum<11;

There is row_number() analytic function.  This is good for pagination and has some other benefits.  

Starting in 12c you have offset and fetch:
https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqlrf/SELECT.html#GUID-CFA006CA-6FF1-4972-821E-6996142A51C6
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark GeerlingsDatabase AdministratorCommented:
Some more information from you on exactly why you want to limit the number of rows returned, or which business problem prompted this question would be helpful for us.

Also, be aware that some of the methods available to limit the rows returned may still cause slow performance, because they may force Oracle to read (and possibly sort) all of the possible rows before determining which rows to return.  So, if the table you are querying is large and if you don't provide "where" clause conditions that help Oracle avoid reading most of the table, just applying a limit to the number of rows to return may still cause a query to be slow.
0
kdschoolAuthor Commented:
It worked perfect.  I just need to narrow my test cases down to evaluate the data against the application.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.