Results 1 to 4 of 4

Thread: SQL hlep

  1. #1
    Join Date
    Oct 2003
    Posts
    5

    Unanswered: SQL hlep

    I just want to select 300 records from a table, how do I do that in SQL ?
    is there a special option I can set? please help

  2. #2
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    Hi,

    To select the first 300 rows from a table use

    Select *
    from table
    where rownum < 301

    However if your DB does not use support rownum, then add
    GROUP BY list
    HAVING COUNT(*) = x
    where list = select list

    or If you want to select all x rows past a rownum (ie, select the next 200 rows after row 300) then this will work, again replace rownum if DB doesn't support it. In addition you can replace the select..minus in the from clause with a view, if this will be done frequently.

    select list
    from
    (select *
    from table
    minus
    select *
    from table
    where rownum < 301)
    group by list
    having count(*) = x
    Last edited by r123456; 12-02-03 at 00:44.
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  3. #3
    Join Date
    Oct 2003
    Posts
    5
    Thanks heaps!

    Originally posted by r123456
    Hi,

    To select the first 300 rows from a table use

    Select *
    from table
    where rownum < 301

    However if your DB does not use support rownum, then add
    GROUP BY list
    HAVING COUNT(*) = x
    where list = select list

    or If you want to select all x rows past a rownum (ie, select the next 200 rows after row 300) then this will work, again replace rownum if DB doesn't support it. In addition you can replace the select..minus in the from clause with a view, if this will be done frequently.

    select list
    from
    (select *
    from table
    minus
    select *
    from table
    where rownum < 301)
    group by list
    having count(*) = x

  4. #4
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    correction,

    rownum = x works fine.
    Last edited by r123456; 12-04-03 at 00:35.
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Posting Permissions

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