Which of the following statements is TRUE with respect to SQL:
(A) AVG(COLUMN): returns the average of the non-null values in the column
(B) COUNT(COLUMN): returns the number of null values in the column
(C) MAX(COLUMN): returns the highest of the non-null values in the column
(D) SUM(COLUMN): returns the sum of the non-null values in the column
Which of the following statements is TRUE with respect to SQL:
(A) AVG(COLUMN): returns the average of the non-null values in the column
(B) COUNT(COLUMN): returns the number of null values in the column
(C) MAX(COLUMN): returns the highest of the non-null values in the column
(D) SUM(COLUMN): returns the sum of the non-null values in the column
Solution
SQL aggregate functions ignore NULLs when they work on a column. So AVG(COLUMN), MAX(COLUMN) and SUM(COLUMN) each use only the non-null values, which makes (A), (C) and (D) true.
(B) is the trap: COUNT(COLUMN) returns the number of non-null values in the column, not the number of nulls. Only COUNT(*) counts every row, including those with nulls.
Related questions:
2025: 14 May Shift 1
2025: 20 May Shift 1