Dividision Within a SQL Statement With Decimal Results

I was surprised to find that this SQL statement does not return .36 as I had expected:

select 36/100 as ShowPercent

From some online searching I found a post which commented that a decimal result from a division operation would not display properly if both of the values were integers. I have no idea why, but that does seem to be true. The change I made to get the correct result was:

select 36/cast(100 as float) as ShowPercent

~Brad

blog comments powered by Disqus
Tagged as: , , , ,