• You say that salary * 115 / 100 and (salary * 115) / 100 return different results due to operator precedence - I can't see how operator precedence makes any difference in this scenario. Could you elaborate or provide an example?

    Basically :

    salary x (115/100) = (salary x 115)/100 so operator precedence should make no difference...

    Actually - thinking about it, is it the integer division that's the issue? What I say above is true in a pure mathematical sense, but if you divide 115/100 as integers in SQLServer, you get 1. If however you divide 115 as a decimal /100, then you get 1.150000, and the calculation will work in any layout. So technically it's the operator precedence causing the integer divide to happen first which is the issue I suppose... though it's the integer divide in its own right that means there is any confusion to be had in the first place.

    declare @percentage decimal(3,0)

    set @percentage = 115 -- Even works with an 'integer' decimal.

    select 3000 * @percentage / 100

    select (3000 * @percentage) / 100

    select 3000 * (@percentage / 100.0)

    Cheers

    -- Kev

    -------------------------------Oh no!