Beginner

383. SUM Function

Learn how to calculate the total of numeric values.

📘 Lesson 383 of 728 ⏱ 9 min 🎯 Beginner

SUM is an aggregate function that calculates the total of non-NULL numeric values in a column or expression.

Total values are fundamental to sales, revenue, expenses, salaries, transactions, and financial analysis.

Calculate total sales amount.

SQL
SELECT
    SUM(SalesAmount) AS TotalSales
FROM Sales;

SUM is widely used in financial reports, sales analysis, revenue calculations, expense analysis, and business dashboards.

  • SUM calculates totals.
  • It works with numeric expressions.
  • NULL values are generally ignored.
  • It can be combined with GROUP BY.
  • It is commonly used for financial analysis.
What does SUM do?

SUM calculates the total of non-NULL numeric values.

Can SUM be used with GROUP BY?

Yes. SUM is commonly used with GROUP BY to calculate totals for each category.

Have you finished this lesson?

Introduction to SQL – All Lessons