Hi, I want to calculate the winner by fulfilling these following conditions. For example I gave a Winner list at the bottom of this page.
Conditions:
1. The Winner will be he, who achieved maximum Sales
2. Department "A" winners cannot exit 6
[TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64, align: left"][TABLE="width: 362"]
<tbody>[TR]
[TD="align: left"]3. Department "B" winners cannot be more than 3[/TD]
[/TR]
[TR]
[TD="align: left"]4. Department "c" winners cannot be more than 1
[/TD]
[/TR]
[TR]
[TD="align: left"]5. Group "X" winners cannot exit 6[/TD]
[/TR]
[TR]
[TD="align: left"]6. Group "Y" winners cannot exit 3[/TD]
[/TR]
[TR]
[TD="align: left"]7. Group "Z" winners cannot exit 1
----------------------
Data:
[TABLE="width: 333"]
<tbody>[TR]
[TD]Group[/TD]
[TD]Department[/TD]
[TD]Sales (amount)[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]B[/TD]
[TD]14500[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]13500[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]B[/TD]
[TD]13000[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]8567[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]5000[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]A[/TD]
[TD]5000[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]A[/TD]
[TD]4750[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]4000[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]3750[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]C[/TD]
[TD]3309[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]A[/TD]
[TD]2000[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]C[/TD]
[TD]1905[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]C[/TD]
[TD]1500[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]950[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]B[/TD]
[TD]900[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]B[/TD]
[TD]850[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]850[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]C[/TD]
[TD]800[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]A[/TD]
[TD]750[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]A[/TD]
[TD]700[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]B[/TD]
[TD]700[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]A[/TD]
[TD]600[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]A[/TD]
[TD]500[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]A[/TD]
[TD]500[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]A[/TD]
[TD]400[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]B[/TD]
[TD]350[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]300[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]A[/TD]
[TD]290[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]275[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]C[/TD]
[TD]250[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]B[/TD]
[TD]250[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]B[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]B[/TD]
[TD]100[/TD]
[/TR]
</tbody>[/TABLE]
-------------------------------------
Example based on above Data:
[TABLE="width: 470"]
<tbody>[TR]
[TD]RANK[/TD]
[TD]Group[/TD]
[TD]Department[/TD]
[TD]Sales[/TD]
[TD]Result[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Z[/TD]
[TD]B[/TD]
[TD] 14,500[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]X[/TD]
[TD]A[/TD]
[TD] 13,500[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]y[/TD]
[TD]B[/TD]
[TD] 13,000[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]X[/TD]
[TD]A[/TD]
[TD] 8,567[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Y[/TD]
[TD]A[/TD]
[TD] 5,000[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Y[/TD]
[TD]A[/TD]
[TD] 4,750[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]X[/TD]
[TD]A[/TD]
[TD] 3,750[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]X[/TD]
[TD]C[/TD]
[TD] 1,500[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]X[/TD]
[TD]A[/TD]
[TD] 950[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]X[/TD]
[TD]B[/TD]
[TD] 900[/TD]
[TD]Winner[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
Conditions:
1. The Winner will be he, who achieved maximum Sales
2. Department "A" winners cannot exit 6
[TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64, align: left"][TABLE="width: 362"]
<tbody>[TR]
[TD="align: left"]3. Department "B" winners cannot be more than 3[/TD]
[/TR]
[TR]
[TD="align: left"]4. Department "c" winners cannot be more than 1
[/TD]
[/TR]
[TR]
[TD="align: left"]5. Group "X" winners cannot exit 6[/TD]
[/TR]
[TR]
[TD="align: left"]6. Group "Y" winners cannot exit 3[/TD]
[/TR]
[TR]
[TD="align: left"]7. Group "Z" winners cannot exit 1
----------------------
Data:
[TABLE="width: 333"]
<tbody>[TR]
[TD]Group[/TD]
[TD]Department[/TD]
[TD]Sales (amount)[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]B[/TD]
[TD]14500[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]13500[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]B[/TD]
[TD]13000[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]8567[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]5000[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]A[/TD]
[TD]5000[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]A[/TD]
[TD]4750[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]4000[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]3750[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]C[/TD]
[TD]3309[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]A[/TD]
[TD]2000[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]C[/TD]
[TD]1905[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]C[/TD]
[TD]1500[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]950[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]B[/TD]
[TD]900[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]B[/TD]
[TD]850[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]850[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]C[/TD]
[TD]800[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]A[/TD]
[TD]750[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]A[/TD]
[TD]700[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]B[/TD]
[TD]700[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]A[/TD]
[TD]600[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]A[/TD]
[TD]500[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]A[/TD]
[TD]500[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]A[/TD]
[TD]400[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD]B[/TD]
[TD]350[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]300[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]A[/TD]
[TD]290[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]A[/TD]
[TD]275[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]C[/TD]
[TD]250[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]B[/TD]
[TD]250[/TD]
[/TR]
[TR]
[TD]x[/TD]
[TD]B[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]z[/TD]
[TD]B[/TD]
[TD]100[/TD]
[/TR]
</tbody>[/TABLE]
-------------------------------------
Example based on above Data:
[TABLE="width: 470"]
<tbody>[TR]
[TD]RANK[/TD]
[TD]Group[/TD]
[TD]Department[/TD]
[TD]Sales[/TD]
[TD]Result[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Z[/TD]
[TD]B[/TD]
[TD] 14,500[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]X[/TD]
[TD]A[/TD]
[TD] 13,500[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]y[/TD]
[TD]B[/TD]
[TD] 13,000[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]X[/TD]
[TD]A[/TD]
[TD] 8,567[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Y[/TD]
[TD]A[/TD]
[TD] 5,000[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Y[/TD]
[TD]A[/TD]
[TD] 4,750[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]X[/TD]
[TD]A[/TD]
[TD] 3,750[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]X[/TD]
[TD]C[/TD]
[TD] 1,500[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]X[/TD]
[TD]A[/TD]
[TD] 950[/TD]
[TD]Winner[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]X[/TD]
[TD]B[/TD]
[TD] 900[/TD]
[TD]Winner[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]