Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> dividing to group with the same weight
Hello,
I would like to write a query (probably with analytic functions) that when given the 'weight' (for example salary) , it distributes the salary between X groups with the same (more or less) weight.
example:
1,2,1,4,4,2,30,1,2,7,3,9,1 (X=3)
30 9 7 4 4 2 3 1 2 1 1 1 ------------------------- 30 18 18
the algorithm that I am using is:
1. sort the weight in a descending order
2. put the entry in the group with the less weight.
when dealing with a very large number or records, the result will be group with more or less the same weight.
thanks
Lior
Received on Wed Feb 08 2006 - 09:52:33 CST