How to get 20rows at a time?
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 7 of 7

Thread: How to get 20rows at a time?

  1. #1
    Join Date
    Jan 2001
    Posts
    642
    Hi,
    In my application, I have to display 20 rows at a time when I click on a button(Using SERVLET).

    what is the query for retreiving data between 21 to 40 records and so on...!

    badrinath

  2. #2
    Join Date
    Mar 2001
    Location
    Ireland/Dublin
    Posts
    684
    Try that

    select rownum,mem_id from member_tbl group by rownum,mem_id
    having rownum between 21 and 40;

    Best wishes!
    Dmitri

  3. #3
    Join Date
    Feb 2000
    Location
    New York,U.S.A.
    Posts
    245
    for example,if you want to have records from 10 to 20
    do
    select * from emp where rownum < 21
    minus
    select * from emp where rownum < 11;

    Dragon

  4. #4
    Join Date
    Jan 2001
    Posts
    642
    KGB,
    This sql is a better one and works effectively
    Badrinath

  5. #5
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    Search for 'Window ROWNUM' on this forum and follow all the threads on this topic.

    Here is one of them:
    http://www.dbasupport.com/forums/sho...?threadid=5480

    Here is the example from the threads:

    SELECT
    ---OUTER.C1
    FROM
    ---(
    ------SELECT
    ---------INNER.C1,
    ---------ROWNUM
    ------------AS QUERY_ROWNUM
    ------FROM
    ---------(
    ---------SELECT
    ------------C1
    ---------FROM
    ------------TABLE1
    ---------ORDER BY
    ------------C1
    ---------) INNER
    ------WHERE
    ---------ROWNUM (LESS THAN) 8
    ---) OUTER
    WHERE
    ---OUTER.QUERY_ROWNUM >= 4

    This is the best way to implement 'windowing' through a result set. The minus implementation is not optimal and kgb's example will not work if you need to do an ORDER BY, which is almost always a requirement of windowing.

    HTH,

    - Chris

  6. #6
    Join Date
    Apr 2001
    Posts
    118
    Hey chrisrlong,

    When you are composing your messages, type &lt; to get the < character. Keeps you from having to type (LESS THAN) in your examples.

    I know that has been bugging you for a while. :)

    HTH,

    Heath

  7. #7
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    haha

    &lt&lt&lt&lt&lt&lt&lt&lt&lt&lt&lt&lt

    Cool!

    Thanks,

    - Chris

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