Skip to main content
SQL • LESSON 90

JOIN with SUM

How can we calculate total customer spending?

Advanced3 Minutes1030 XP
🤔 THE QUESTION

How can we calculate total customer spending?

💡 WHAT IS IT?

SUM() over joined transaction records aggregates monetary totals grouped by customer.

🎯 WHAT IS IT USED FOR?

Customer lifetime spend, revenue contribution by account, billing rollups.

💻 EXAMPLE
SELECT c.customer_name, SUM(o.amount) AS total_spent
FROM customers c
JOIN orders o
ON c.customer_id = o.customer_id
GROUP BY c.customer_name;

🎯 Mission Objectives

Practice typing production-grade SQL code for JOIN with SUM.

  • JOIN + SUM
  • Revenue rollups
  • Customer lifetime spend
  • Financial analytics