Mga Grupo sa Google : microsoft.public.sqlserver.programming: "The description of what 'Bankers Rounding' is, really helps.
It's a bit tricky, but this should do the trick:
round( NumToRound - (cast( cast(NumToRound+1 as int) % 2 as
decimal(10,1))/10) , 0 )
What it basically does, is use the Modulo function (%) to determine if
it's an even number or not. Because by default .5 is rounded up, I
needed a 1 for even number, that's why the modulo is done over
NumToRound + 1. This 1 is then translated to .1, and this is enough
correction to have 2.5 rounded down. "
0 Comments:
Post a Comment
<< Home