Quote:
|
Originally Posted by ahmedwaseem2000
and what would be the result if the aggregating column something like this sum(10 + null) as column1?
|
Also NULL: SUM(expr) only includes rows for which the expression is not NULL. If there is at least one such row, the result is not NULL, otherwise it is.
With AVG(expr) it's even more apparent: the denominator will be the number of rows for which expr is not NULL.
Actually, the same holds for any of the other aggregate functions:
COUNT(expr) only counts the number of not NULL expr's.
In that respect, COUNT(*) is actually equivalent to COUNT(1).
MIN(expr) and MAX(expr) equally ignore NULL expressions.
All (except for COUNT(expr) of course) return NULL when applied on an empty set, i.e., either an empty table (after having applied the WHERE condition), or an empty list (after removal of the NULL expressions).