On 9/8/05, D. Richard Hipp <[EMAIL PROTECTED]> wrote: > PostgreSQL docs say that NULL is returned if all inputs > to sum are NULL. > > So then, if there are no input rows at all (if no rows > match the WHERE clause) then SUM returns 0. Actually PostgreSQL 8.0.3 and FirebirdSQL 1.5.2 return NULL in this case too.
> (This makes > sense because if you say: > > SELECT sum(amt) FROM sales WHERE month='october'; > I agree that this does make sense in some cases, and it can also be quite handy to distinguish between 'no rows matched WHERE clause' and 'all matching rows were NULL'. But it appears it's not very consistent with other DB engines. -- Nemanja Corlija <[EMAIL PROTECTED]>