Subject | RE: [ib-support] Why does SUM() return null? |
---|---|
Author | Martijn Tonies |
Post date | 2002-02-19T09:35:44Z |
Hi there,
according to the SQL92 standard:
===
Set Function Specification
... bla bla bla ...
<set function type> ::=
AVG | MAX | MIN | SUM | COUNT
... bla bla bla ...
General Rules
1) Case:
a) If COUNT(*) is specified, then the result is the cardinality
of T.
b) Otherwise, let TX be the single-column table that is the
result of applying the <value expression> to each row of T
and eliminating null values. If one or more null values are
eliminated, then a completion condition is raised: warning-
null value eliminated in set function.
... bla bla bla ...
b) If AVG, MAX, MIN, or SUM is specified, then
Case:
i) If TXA is empty, then the result is the null value.
===
Where, I believe, TXA is the resultset -> hence, the NULL result. No
resultset, the function returns 'NULL'.
And that is why SUM(no result) returns NULL
Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird
http://www.interbaseworkbench.com
[Non-text portions of this message have been removed]
according to the SQL92 standard:
===
Set Function Specification
... bla bla bla ...
<set function type> ::=
AVG | MAX | MIN | SUM | COUNT
... bla bla bla ...
General Rules
1) Case:
a) If COUNT(*) is specified, then the result is the cardinality
of T.
b) Otherwise, let TX be the single-column table that is the
result of applying the <value expression> to each row of T
and eliminating null values. If one or more null values are
eliminated, then a completion condition is raised: warning-
null value eliminated in set function.
... bla bla bla ...
b) If AVG, MAX, MIN, or SUM is specified, then
Case:
i) If TXA is empty, then the result is the null value.
===
Where, I believe, TXA is the resultset -> hence, the NULL result. No
resultset, the function returns 'NULL'.
And that is why SUM(no result) returns NULL
Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird
http://www.interbaseworkbench.com
[Non-text portions of this message have been removed]