SQL • LESSON 10

GROUP BY

Learn how to group SQL records and calculate results for each group.

🟡 Intermediate⏱ 2 Minutes⭐ 180 XP
🤔 THE QUESTION

How can we calculate the average salary of all employees?

💡 WHAT IS IT?

AVG() is an aggregate function that calculates the average value of a numeric column.

🎯 WHAT IS IT USED FOR?

It is commonly used for salary analysis, average sales, average scores, performance metrics, and other numerical summaries.

💻 EXAMPLE
SELECT AVG(salary) AS average_salary
FROM employees;

Mission Brief

Practice grouping employee records by department and counting employees in each department.

Objectives

  • SELECT
  • COUNT
  • FROM
  • GROUP BY
  • Aliases