$ ./guess_the_languageSQL & Databases
SQL & Databases · medium · #15

What does the query return?

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