In PostgreSQL 18, table m has 4 rows and its column v holds the values 1, NULL, 2 and NULL. What does SELECT count(*), count(v), count(DISTINCT v) FROM m; return?
Explanation
count(*) counts input rows regardless of content, while count(v) counts only rows where v is not null, and count(DISTINCT v) counts distinct non-null values. The answer 3 comes from expecting NULL to be counted as one more distinct value.