Question : msSQL reporting

Hello Experts, I am generating some reports where i calculate the percetages for different values. At the end I sum up all the percetages and it has to come up to 100%.
The thing is that, I am taking the approximate values to some up and sometimes the sum of percetanges comes up as 101, or 102 percent. I was wondering if there is any command I can have to not allow the value to be more then 100.
I mean if the sum is 101%, say 100%

Any help or suggestion really appreciated.

Thanks in advance

/* total Percentages */
Set @TotalParticipantNr_BeginP = (Sum(@CVD12Nr_BeginP + @CVD34Nr_BeginP + @CVD56Nr_BeginP + @CVD78Nr_BeginP + @CVD910Nr_BeginP /*+ @IDONTKNOWNr_BeginP */+ @MissedNr_BeginP))
1:
2:
3:
4:
/* total Percentages */
Set @TotalParticipantNr_BeginP = (Sum(@CVD12Nr_BeginP + @CVD34Nr_BeginP + @CVD56Nr_BeginP + @CVD78Nr_BeginP + @CVD910Nr_BeginP + @IDONTKNOWNr_BeginP + @MissedNr_BeginP))

this sum sometimes get 101 %

Answer : msSQL reporting

Set @TotalParticipantNr_BeginP =
CASE WHEN
(Sum(@CVD12Nr_BeginP + @CVD34Nr_BeginP + @CVD56Nr_BeginP + @CVD78Nr_BeginP + @CVD910Nr_BeginP + @IDONTKNOWNr_BeginP + @MissedNr_BeginP)) > 100 then 100 else
Set @TotalParticipantNr_BeginP = (Sum(@CVD12Nr_BeginP + @CVD34Nr_BeginP + @CVD56Nr_BeginP + @CVD78Nr_BeginP + @CVD910Nr_BeginP + @IDONTKNOWNr_BeginP + @MissedNr_BeginP))
end


That is a workaround.
The problem is that when you round things up at each point, you inevitably get a sum that is not equal to the total.
Simple case of two components that end up with 45.5 and 54.5.
If you show them at a round number, they will be 46 and 55.  46+55 = 101.
Random Solutions  
 
programming4us programming4us