Aggregation & GROUP BY · SQL SQL

How do standard SQL aggregate functions (such as COUNT, SUM, AVG) handle NULL values in their input columns?

Practice question from Aggregation & GROUP BY (SQL SQL), with the correct answer and a step-by-step solution.

easy · MCQ · Q-DB103D

How do standard SQL aggregate functions (such as COUNT, SUM, AVG) handle NULL values in their input columns?

  1. A.They treat NULL values as zero.
  2. B.They include NULL values in the total row count.
  3. C.They ignore/exclude NULL values from the calculation.Correct answer
  4. D.They cause the entire query to abort and return an error.

Solution

All standard SQL aggregate functions (except COUNT(*)) automatically ignore NULL values within the evaluated column. For example, AVG(salary) computes the average using only rows where salary is not NULL.

More from Aggregation & GROUP BY

All of Aggregation & GROUP BY

Practise more SQL

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed