Friday, March 13, 2009

How to calculate Average with 2 decimal places in SQL Server

I have following query to find average in SQL Server
select top 10 cast(avg(cast(DATEDIFF(day, createdate, getdate()) as decimal)) as decimal(18,2)) as avgDays from tblTemp
Is there any optimized way to find average upto two decimal places? Thanks.