QuestenaPractice that shows what to review next
Question 17

In PostgreSQL 18, what does SELECT count(*), sum(v) FROM m WHERE false; return, given that the WHERE clause removes every row?

  1. One row containing 0 and NULLCorrect answer
  2. No rows at all
  3. One row containing 0 and 0
  4. One row containing NULL and NULL

Explanation

An aggregate query without GROUP BY always yields exactly one row, and count is the exception that returns 0 over an empty input while the other aggregates return null. Expecting 0 and 0 is the classic cause of a null slipping into a total; coalesce(sum(v), 0) is the usual guard.

Continue with this test

Start practice
Question 17: In PostgreSQL 18, what does SELECT count(*), sum(v) FROM m… · SQL: NULL, Joins and Aggregates · Questena