Bird
0
0

Consider a table employees with a column bonus having values (NULL, 500, NULL, 1000). What does the query SELECT AVG(bonus) FROM employees; return?

medium📝 query result Q5 of 15
SQL - Aggregate Functions
Consider a table employees with a column bonus having values (NULL, 500, NULL, 1000). What does the query SELECT AVG(bonus) FROM employees; return?
A375
B500
CNULL
D750
Step-by-Step Solution
Solution:
  1. Step 1: AVG ignores NULLs and averages non-NULL values

    Non-NULL bonuses are 500 and 1000.
  2. Step 2: Calculate average

    (500 + 1000) / 2 = 750.
  3. Final Answer:

    750 -> Option D
  4. Quick Check:

    AVG excludes NULLs, averages non-NULL values = B [OK]
Quick Trick: AVG ignores NULLs, averages only non-NULL values [OK]
Common Mistakes:
MISTAKES
  • Including NULLs as zero in average
  • Returning NULL if any NULL exists
  • Dividing by total rows including NULLs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes