SQL • LESSON 12

Aggregate Queries

Combine aggregate functions, grouping, and filtering to analyze SQL data.

🔴 Advanced⏱ 3 Minutes⭐ 220 XP
🤔 THE QUESTION

How can we calculate the total value stored in a numeric column?

💡 WHAT IS IT?

SUM() is an aggregate function that adds together the values in a column.

🎯 WHAT IS IT USED FOR?

It is commonly used for total sales, revenue, expenses, quantities, salaries, and other numerical totals.

💻 EXAMPLE
SELECT SUM(salary) AS total_salary
FROM employees;

Mission Brief

Practice building a complete aggregate query using COUNT, AVG, GROUP BY, and HAVING.

Objectives

  • SELECT
  • COUNT
  • AVG
  • GROUP BY
  • HAVING