SUM function in SQL

The SUM function in SQL is an aggregate function that calculates the total sum of a numeric column.

SQL Syntax

SELECT SUM(column_name)
FROM table_name
WHERE condition;

Example: Suppose we have a table sales with the following structure:

sale_idemployee_idamount
11500
22300
31700
43200
52400
63600
71300

To find the total sales amount:

SQL

SELECT SUM(amount) AS total_sales
FROM sales;

The result of the above query is shown below:

total_sales
3000