My Co-worker complained me that AVG function is not properly working in SQL Server whereas it works correctly in mysql. I immediately told him that AVG does the implicit convertion by default and the result may be wrong (based on datatype).
Consider the following set of data
select avg(col) from ( select 1 as col union all select 2 ) as t
average ----------- 1
select avg(col*1.0) as average,avg(cast(col as decimal(12,2))) as average from ( select 1 as col union all select 2 ) as t
average average --------------------------------------- --------------------------------------- 1.500000 1.500000
Tags: 
Nice post with nice example Madhivanan. Thanks for sharing.
Nice, concise post. Thank-you, Madhivanan!