QuestenaPractice that shows what to review next
Question 13

In PostgreSQL 18, table emp has 3 rows with dept_id values 10, 20 and NULL, and table dept_null has exactly one row whose id is NULL. How many rows does SELECT * FROM emp e JOIN dept_null d ON d.id = e.dept_id; return?

  1. 0Correct answer
  2. 3
  3. 1
  4. 2

Explanation

A pair of rows matches only when the ON expression evaluates to true, and NULL = NULL evaluates to null, so the null dept_id never pairs with the null id. Answering 1 reads the join as matching identical values; writing ON d.id IS NOT DISTINCT FROM e.dept_id is what produces that row.

Continue with this test

Start practice
Question 13: In PostgreSQL 18, table emp has 3 rows with dept_id values… · SQL: NULL, Joins and Aggregates · Questena