SUM

SUM ([DISTINCT] expression)

Parameters

  • DISTINCT - specifies to accumulate unique values only.
  • expression - may be a column name, the result of another function, or a math operation.

Description

Returns a sum of all values. If no entries are selected, the result is NULL. Aggregates are only allowed in select statements. The data type of the returned value depends on the parameter data.

Example

Get a total goals number scored by all players:

SELECT SUM(goal) FROM Players;