DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: Ask for between row selection

  1. #1
    Join Date
    Mar 2001
    Posts
    18

    Ask for between row selection

    Dear all,


    We have 100 records(tbl_name), now we create the 4 views(viw_1, viw_2, viw_3, viw_4) for each 25 records. It means 1st is first top 25, 2nd is second top 25 and so on.
    Can u help me?

    Thx

  2. #2
    Join Date
    Aug 2001
    Location
    Waterloo, On
    Posts
    547
    You will have to use 'top n' query. Syntax can be found in Oracle documentation.
    A crude method is to use the ROWNUM pseudocolumn. Eg Select * from your_table where rownum between 25 and 50;

    Raminder Singh

    Oracle Certified DBA: Oracle 8i, 9i


    Mail me at raminderahluwalia@rediffmail.com.

  3. #3
    Join Date
    Aug 2000
    Location
    Belgium
    Posts
    342
    or you could use the row_number() analytical function

    HTH
    Gert

  4. #4
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    Originally posted by Raminder
    A crude method is to use the ROWNUM pseudocolumn. Eg Select * from your_table where rownum between 25 and 50;
    I don't see how this would be defined as 'crude', as this is the proper way to do 'windowing', which is very similar to this request.

    However, I must ask - why in the world do you want to do this at all? It is a very odd request.

    - Chris
    Christopher R. Long
    ChrisRLong@HotMail.Com
    But that's just my opinion. I could be wrong

  5. #5
    Join Date
    Aug 2001
    Location
    Manchester, UK
    Posts
    86
    ------------------
    However, I must ask - why in the world do you want to do this at all? It is a very odd request.
    -------------------

    I use it quite regularly where the client requires the data to be seperated in 4-5 sets and then apply different rules on each set.

    You can do it as

    select *
    from ( select a.*, rownum rnum
    from ( YOUR_QUERY_GOES_HERE -- including the order by ) a
    where rownum <= MAX_ROWS )
    where rnum >= MIN_ROWS
    -- Anurag.
    OCP Application Developer
    ---------------------------------------------------------
    "Be not afraid of growing slowly. Be afraid only of standing still."

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