Skip to main content
SQL • LESSON 68

Aggregate with Filter

How can we calculate the average salary only for engineers?

Intermediate3 Minutes810 XP
🤔 THE QUESTION

How can we calculate the average salary only for engineers?

💡 WHAT IS IT?

The WHERE clause restricts rows before aggregation functions are evaluated.

🎯 WHAT IS IT USED FOR?

Segmented averages, department KPIs, filtered spend analytics.

💻 EXAMPLE
SELECT AVG(salary) AS average_engineering_salary
FROM employees
WHERE department = 'Engineering';

🎯 Mission Objectives

Practice typing production-grade SQL code for Aggregate with Filter.

  • Filtered aggregation
  • WHERE before aggregate
  • Department statistics
  • Targeted metrics