Lesson 18: Summing all values using the SUM Function.

By Alan Hylands — 1 minute read

The SUM function allows you to do a summary calculation on a particular column in your data table. No wildcards here, we MUST specify the individual column we want to summarise.

The easiest way to think about the SUM function is to use it to add up all of the values in a particular column. If we want to find the total number of international caps for our football players, our SQL query would look like this:

1Peter Shilton125
2Pat Jennings119
3Bobby Moore108
4Diego Maradona91
FROM footballers;

(Answer: 443)

Quiz Time.

The Question.

It's not all about the price tag when it comes to making these movies. Not unless you are a studio executive looking to see how big of a cheque you are going to have to write to get one made.

Let's pretend you are Marvel's accountant for a second. Get the total budget for all four Avengers movies (and remember these budget figures are in MILLIONS of US dollars).

The Data.

The Editor.


Show Answer

The Answer.

Correct SQL:

                    SELECT SUM(budget) FROM movies;

Correct Output:

Try the next lesson