AVG#
Returns the average of the values in a group. Null values are ignored.
Syntax#
AVG ( [ ALL | DISTINCT ] expression )
OVER ( [ partition_by_clause ] order_by_clause )
Arguments#
expression
Is an expression of the exact numeric or approximate numeric data type category, except for the bit data type. Aggregate functions and subqueries are not permitted.
Return types#
The return type is determined by the type of the evaluated result of an expression. It could be one of: bigint, decimal, modey, float, int.
Examples#
SELECT AVG([MoneyValue]) AS [Avg]
FROM [DataTable]
SELECT AVG([FloatValue]) OVER (PARTITION BY [IdNullable] ORDER BY [IntValue]) AS AVGGG
FROM [DataTable]