aggregate of an empty result set

Viewed 15463

I would like the aggregates of an empty result set to be 0. I have tried the following:

SELECT SUM(COALESCE(capacity, 0))
  FROM objects
 WHERE null IS NOT NULL;

Result:

sum 
-----

(1 row)

Subquestion: wouldn't the above work in Oracle, using SUM(NVL(capacity, 0))?

4 Answers
Related