Skip to main content
SQL โ€ข LESSON 70

GROUP BY with SUM

How can we calculate total salary by department?

Intermediateโฑ 3 Minutesโญ 830 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