Built-in Functions → sum

sum() is an aggregation function that returns the sum of the values in a column.

Signature

sum(double[] exp)

double[] exp : expression evaluating to double

Returns

double representing the sum of the values in the column.

Example

Consider the following table of example data:

Year Quarter Month Amount Sold
2019 Q1 M1 100
2019 Q1 M2 200
2019 Q1 M3 100
2019 Q2 M4 150
2019 Q2 M5 250
2019 Q2 M6 150
2019 Q3 M7 200
2019 Q3 M8 250
2019 Q3 M9 300
2019 Q4 M10 100
2019 Q4 M11 50
2019 Q4 M12 50
2020 Q1 M1 150
2020 Q1 M2 100
2020 Q1 M3 200
2020 Q2 M4 150
2020 Q2 M5 100
2020 Q2 M6 150
2020 Q3 M7 50
2020 Q3 M8 100
2020 Q3 M9 200
2020 Q4 M10 150
2020 Q4 M11 100
2020 Q4 M12 50

Find the total amount sold (add up the values in the Amount Sold column).

sum(AMOUNT_SOLD)