Bird
0
0

Consider the table Employees with salaries:

medium📝 query result Q5 of 15
SQL - Aggregate Functions
Consider the table Employees with salaries:
5000, 7000, NULL, 6000
What does the query SELECT AVG(salary) FROM Employees WHERE salary > 5500; return?
ANULL
B6000
C6500
D7000
Step-by-Step Solution
Solution:
  1. Step 1: Filter salaries greater than 5500

    Values are 7000 and 6000; NULL is ignored.
  2. Step 2: Calculate average of filtered values

    (7000 + 6000) / 2 = 13000 / 2 = 6500.
  3. Final Answer:

    6500 -> Option C
  4. Quick Check:

    AVG() with WHERE filters values = 6500 [OK]
Quick Trick: WHERE filters rows before AVG() calculation [OK]
Common Mistakes:
MISTAKES
  • Including NULL in average
  • Not applying WHERE filter before AVG()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes