What does the query return?
SELECT SUM(amount) FROM orders WHERE 1 = 0;
- NULL
- An error
- No row
- 0
With no input rows,
Play SQL & Databases ▸
SUM returns a single row holding NULL, not 0; wrap it in COALESCE if you need zero.