MariaDB SUM Function
MariaDB SUM function is used to return the summed value of an expression.
SELECT SUM(aggregate_expression) FROM tables [WHERE conditions];
# SUM () Function with Single Expression
Calculate the total salary of the "Student" table where "student_id" is greater than 1.
SELECT SUM(salary) AS "Total Salary" FROM Student WHERE student_id > 1;
# SUM () Function with DISTINCT Clause
You can use DISTINCT clause with SUM function to avoid duplicate values summation.
SELECT SUM(DISTINCT salary) AS "Total Salary" FROM Student WHERE student_name = 'Mahesh';