skip to today's puzzle

SUM adds up a whole column

Starting table: shifts

Starting shifts data before the example query
idtip
130
242.5
325
445

SUM takes one column of numbers and returns the total. Like COUNT, it turns many rows into one answer, so a single number appears in your results rather than a list of rows.

A tiny example

In plain English: Tell me the total of all the tips from every shift.

SELECT SUM(tip)
FROM shifts;

Query result

SUM(tip)
142.5

Every tip from every shift added together comes to 142.5.

Common questions

What does SUM do with NULL values?
It skips them. SUM adds up only the rows where the column has a value, so a NULL never changes the total.
How do I get a total per group instead of one grand total?
Add GROUP BY, such as SELECT city, SUM(total) FROM orders GROUP BY city. Each city gets its own row with its own total.

Related SQL lessons

Practice SUM step by step

The Foundations Track has beginner puzzles built around this idea. Tap tiles, see real results. No terminal, no setup.

practice this in the course

Ready for a break?

A fresh, bite-sized SQL puzzle waits every morning. Tap tiles, see real results. No terminal, no setup, no timers.

Try today's free SQL puzzle