PostgreSQL NULL Handling and Aggregates: Intermediate Test
This intermediate PostgreSQL test covers NULL handling and aggregate functions, where many real reporting bugs come from. Questions check the difference between COUNT(*) and COUNT(column), how AVG and SUM skip NULL values and why SUM over no rows returns NULL while COUNT returns 0, why a WHERE comparison with NULL silently drops rows, the NOT IN subquery that returns nothing when the list contains a NULL, how GROUP BY puts all NULL keys in one group, what IS DISTINCT FROM returns, three-valued logic with AND and OR, how a WHERE condition on the right table turns a LEFT JOIN into an inner join, which aggregates ignore NULL, and where PostgreSQL sorts NULL by default. Every question uses a complete script with temporary tables that you can run in psql in the PostgreSQL sandbox. The test has 10 multiple-choice questions with correct answers and an explanation for each.
Comments