Function to get TOP 100 records
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Function to get TOP 100 records

  1. #1
    Join Date
    Mar 2002
    Posts
    1

    Question

    I am trying to create a SQL statement that brings back the first 100 records in a table. You can do this using TOP in SQL Server but it doesn't seem to work on Oracle. Does anyone know what I need to use?

    Thanks

  2. #2
    Join Date
    Feb 2002
    Location
    Dallas , Texas
    Posts
    158
    select * from table_name where rownum <=100;
    take care,
    Nishant.

  3. #3
    Join Date
    Jun 2001
    Location
    Helsinki. Finland
    Posts
    3,938
    Originally posted by nishant
    select * from table_name where rownum <=100;
    take care,
    Nishant.
    Wait a second now! How do we define first and last record of an Oracle table? If you mean last record inserted, there is no way to get it unless you programatically keep a field storing this information.

    Oracle Certified Master
    Oracle Certified Professional 6i,8i,9i,10g,11g
    email: ocp_9i@yahoo.com

  4. #4
    Join Date
    Feb 2002
    Location
    Dallas , Texas
    Posts
    158
    Hi Julian,
    You are right we cannot get the last record inserted till we keep a column to store the value.I think the original question was just to retrive the top 100 records in the table without any mention of whether it was last inserted or first.Do correct me if i am wrong.
    take care,
    Nishant.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width