Search code examples
sqlsql-servert-sql

T-SQL average rounded to the closest integer


I'm not sure if this has been asked before, but how do I get the average rounded to the closest integer in T-SQL?


Solution

  • This worked for it:

    CONVERT(int,ROUND(AVG(CAST(COLUMN-NAME AS DECIMAL)) ,0))
    

    Isn't there a shorter way of doing it though?