Grouping data into buckets
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 7 of 7

Thread: Grouping data into buckets

  1. #1
    Join Date
    Aug 2003
    Posts
    100

    Grouping data into buckets

    Does anyone know how to easily query data in a table into 4 equally sized groups? I have a table with roughly 10K rows and I need to query the data in such a way that each group would have 2500 rows.

    Thanks in advance.

    Steve

  2. #2
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Try "group by mod(rownum,4)"
    Last edited by DaPi; 01-06-2004 at 09:10 AM.

  3. #3
    Join Date
    Jan 2003
    Location
    india
    Posts
    175
    ORA-00979: not a GROUP BY expression

    how can i do without grouping?

  4. #4
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Ugh?
    Code:
     SQL> select mod(rownum,4), count(*)
      2  from   all_objects
      3  group by mod(rownum,4)
      4  /
    
    MOD(ROWNUM,4)   COUNT(*)
    ------------- ----------
                0       2134
                1       2135
                2       2135
                3       2135
    How do I group without grouping ? ?

  5. #5
    Join Date
    Jan 2003
    Location
    india
    Posts
    175
    i don't want the count(*).... group by mod(rownum,4)

    i want the * .... group by mod(rownum,4)

    i mean i want the full row.

  6. #6
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142

    Angry

    Sorry rajabalachandra, I have no idea what you are trying to do . . . .

    Perhaps you could restate your problem with an example of a table to be processed and the result you want?

  7. #7
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    WHY U WANNA DO THIS?
    Cheers!
    OraKid.

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