SQL Sum

The SQL SUM function is used to calculate the total sum of a numeric column by adding all of the numeric values. This function is useful when you need to get the total values in a dataset.

Tutorials dojo strip

SQL Sum Syntax

SQL

SQL Sum Example

SQL Sum with All Rows Example

This query sums up the total length of all contact numbers from the Patients table.

SQL

SQL Sum with a WHERE Clause

This query calculates the total length of contact numbers for all female patients. The WHERE clause limits the rows to those where gender = ‘F’

SQL

SQL Sum with Group By Clause

This query calculates the total length of contact numbers for each gender group. The GROUP BY clause divides the rows by gender.

SQL

SQL Sum Visual Diagram

SQL Sum Labs

Tutorials dojo strip