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 6674059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:42:04+00:00 2026-05-26T03:42:04+00:00

I have a query in oracle to fetch data from table using rownum but

  • 0

I have a query in oracle to fetch data from table using rownum but i didn’t get any data.
My query is like this :

select * from table-name where rownum<5

is this is a wrong query to fetch data whose row number is less than 5.
when i used query like :
select * from table-name where rownum<=4
than it will gives a result record.

My question is what is wrong here with ?
Is this is syntax error or anything else??..

  • 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-26T03:42:05+00:00Added an answer on May 26, 2026 at 3:42 am

    rownum is a pseudo column that counts rows in the result set after the where clause has been applied.

      SELECT table_name
        FROM user_tables
        WHERE rownum > 2;
    TABLE_NAME                     
    ------------------------------
    
    0 rows selected
    

    However, this query will always return zero rows, regardless of the number of rows in the table.

    To explain this behaviour, we need to understand how Oracle processes ROWNUM. When assigning ROWNUM to a row, Oracle starts at 1 and only increments the value when a row is selected; that is, when all conditions in the WHERE clause are met. Since our condition requires that ROWNUM is greater than 2, no rows are selected and ROWNUM is never incremented beyond 1.

    http://blog.lishman.com/2008/03/rownum.html

    another stackoverflow link

    Edited

    this paragraph i find on oracle website which is much better

    Conditions testing for ROWNUM values greater than a positive integer are always false. For example, this query returns no rows:

    SELECT * FROM employees
        WHERE ROWNUM > 1;
    

    The first row fetched is assigned a ROWNUM of 1 and makes the condition false. The second row to be fetched is now the first row and is also assigned a ROWNUM of 1 and makes the condition false. All rows subsequently fail to satisfy the condition, so no rows are returned.

    You can also use ROWNUM to assign unique values to each row of a table, as in this example:

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

Sidebar

Related Questions

I have a mySQL query to get columns from a table like this: String
I have a query which retrieves the data from Oracle DB. The table which
I have a join in a oracle query which looks like: FROM eiv.table1 eiv.table2
I have a query that I am generating the XML from in Oracle using
I have this error when running a large query on oracle. any advice? I'm
I have a query in Oracle for a report that looks like this: SELECT
I have a query: select min(timestamp) from table This table has 60+million rows, and
I have 5 tables, using oracle procedure how to fetch selected columns from these
I have a query like this - SELECT * FROM mytable WHERE id IN()
I have an oracle query to delete rows in a child table, but the

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.