The SQL SUM simply adds up all the value in a set of rows and return the result.
In the other words, SUM function calculate the sum of all the values in particular column.
SUM operator only can use for column whish is content number only like Interger, Float, Double, etc.
The SQL SUM syntax is simple and looks like this:
SELECT SUM ( [COLUMN NAME] ) FROM [TABLE NAME]
EXAMPLE :
We can see with a simple example which is return sum of the scores in the table.
Table GameScores
PlayerName | Department | Scores |
Jason | IT | 3000 |
Irene | IT | 1500 |
Jane | Marketing | 1000 |
David | Marketing | 2500 |
Paul | HR | 2000 |
James | HR | 2000 |
SQL statement :
SELECT SUM(Scores) FROM GameScores
Result:
SUM(Scores) |
12000 |