Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7632377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:36:38+00:00 2026-05-31T06:36:38+00:00

I have the following query: select * from abc where rownum = 10 Output

  • 0

I have the following query:

select * from abc where rownum = 10

Output: No records to display

I sure have more than 25 records in the abc table and my objective is to display the nth record.

If I write the query as: –

select * from abc where rownum = 1

it works fine and gives me the first record. Not any other record other than first.

Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:36:40+00:00Added an answer on May 31, 2026 at 6:36 am

    Because row numbers are assigned sequentially to the rows that are fetched and returned.

    Here’s how that statement of yours works. It grabs the first candidate row and temporarily gives it row number 1, which doesn’t match your condition so it’s thrown away.

    Then you get the second candidate row and it’s also given row number 1 (since the previous one was tossed away). It doesn’t match either.

    Then the third candidate row … well, I’m sure you can see where this is going now. In short, you will never find a row that satisfies that condition.

    Row numbers are only useful for = 1, < something or <= something.

    This is all explained in the Oracle docs for the rownum pseudo-column.

    You should also keep in mind that SQL is a relational algebra that returns unordered sets unless you specify an order. That means row number ten may be something now and something else in three minutes.

    If you want a (kludgy, admittedly) way to get the nth row, you can use something like (for the fifth row):

    select * from (
        select * from (
            select col1, col2, col3 from tbl order by col1 asc
        ) where rownum < 6 order by col1 desc
    ) where rownum = 1
    

    The inner select will ensure you have a consistent order on the query before you start throwing away rows, and the middle select will throw away all but the first five rows from that, and also reverse the order.

    The outer select will then only return the first row of the reversed set (which is the last row of the five-row set when it was in ascending order).

    A better way is probably:

    select * from (
        select rownum rn, col1, col2, col3 from tbl order by col1
    ) where rn = 5
    

    This works by retrieving everything and assigning the rownum to a “real” column, then using that real column number to filter the results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query: select column_name, count(column_name) from table group by column_name having
I have the following query SELECT * FROM table WHERE id IN (5,4,3,1,6) and
I have the following query Select count(*) as TotalCount from ABC where ID in
I have the following query SELECT * FROM attend RIGHT OUTER JOIN noattend ON
Suppose I have the following query: select * from A, B, C, D where
I have the following query: SELECT c.* FROM companies AS c JOIN users AS
I have the following query: SELECT rowid FROM table1 ORDER BY RANDOM() LIMIT 1
I have the following query: SELECT COUNT(*) FROM FirstTable ft INNER JOIN SecondTable st
I have a following HQL query: SELECT s.id FROM stack s WHERE s.category is
I have the following query: SELECT o.id,o.name FROM object o WHERE ( o.description LIKE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.