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?
- A.They treat NULL values as zero.
- B.They include NULL values in the total row count.
- C.They ignore/exclude NULL values from the calculation.Correct answer
- 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
- What is the primary purpose of the SQL HAVING clause in an aggregation query?
- Consider a table named 'employees' with columns 'department' and 'salary'. Which of the following queries correctly returns the average sal…
- In standard SQL (ANSI SQL), if an aggregate function such as SUM() or COUNT() is used in a SELECT list, what rule applies to any other non-…
- What will be the output of COUNT() versus COUNT(columnname) when the specified column contains several NULL values?
Practise more SQL
Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.
Start practising freeFree to start · No credit card needed