Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: dividing to group with the same weight
I did the following:
select name, salary, dept , mod(row_number() over(order by salary
),3) group_no from info_table
order by salary desc;
the answer I got is not exactly what I need, because I do not need the salaries (weight) to be put each time in the following group. I need them in the group with the lowest weight.
I need that if I have the following
20,20,13,5,5,4,4,4,3,2,1,1,1,1,1,1,1
the answer for 3 group will be
20, 20,13
5 5
1, 1
1 1, 1
1
5 ,5 ,4 4 ,4 ,3 2 ,1 ,1 1 ,1 ,1
of course the is always the possibility of opening a cursor and writing a C++ or pl/sql program, but I will be more satisfy if I could get oracle 10g to do it.
I am sorry if you got the impression that I want you do do my work for me. trust me I am working on it too and will supply an answer if I found one. Received on Thu Feb 09 2006 - 03:36:49 CST