Skip to main content
SQL • LESSON 70

GROUP BY with SUM

How can we calculate total salary by department?

Intermediate3 Minutes830 XP
🤔 THE QUESTION

How can we calculate total salary by department?

💡 WHAT IS IT?

GROUP BY with SUM() calculates the total numerical summation for each unique group.

🎯 WHAT IS IT USED FOR?

Departmental budget tracking, regional revenue breakdowns, category spend.

💻 EXAMPLE
SELECT department, SUM(salary) AS total_salary
FROM employees
GROUP BY department;

🎯 Mission Objectives

Practice typing production-grade SQL code for GROUP BY with SUM.

  • GROUP BY + SUM
  • Budget rollups
  • Department totals
  • Categorical sums