

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 6
click for more info
Not enough gems
Cost: 6 gems
1: What Are Aggregations?
incomplete
2: SUM
incomplete
3: MAX
incomplete
4: MIN
incomplete
5: GROUP BY
incomplete
6: Average
incomplete
7: HAVING
incomplete
8: HAVING vs. WHERE in SQL
incomplete
9: ROUND
incomplete
10: Query Practice – Average Ages
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
The SUM aggregation function returns the sum of a set of values.
For example, the query below returns a single record containing a single field. The returned value is equal to the total salary being collected by all of the employees in the employees table.
SELECT SUM(salary)
FROM employees;
Which returns:
| SUM(SALARY) |
|---|
| 2483 |
We need to be able to calculate the current balance for a given user because we don't (yet) store the running balance on each individual transaction record.
Write a query that returns the SUM aggregation of the amounts for all of Bob's successful transactions (user_id is 9). Check the file 001_up.sql for more details about the table.