Friday, October 23, 2015

Retrieve decimals when rounding an average in SQL

The average will have the same data type as the values, so cast the values:

SELECT ROUND(AVG(CAST(column_name AS FLOAT)), 2) FROM [database].[dbo].[table]