Sami Jenedi Sami Jenedi - 10 months ago 75
SQL Question

Would null value change the average?

What will be the result of this query? (Oracle SQL)

SELECT TO_CHAR(AVG(TEST_SCORE),'999,999.99') FROM SCORES;


If the values of TEST_SCORE are (96, 84, null)

isn't 90.00? Because null wouldn't change the answer?

Thank you

Answer Source

A NULL value will not change the average. The average of the two numbers is 90. In general, aggregation functions ignore NULL values -- including min(), max(), avg(), count() (except count(*)), and sum().

Here is a little rextester showing what happens.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download