Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Reporting with SQL!
You have completed Reporting with SQL!
Preview
Calculating grand totals are handy for answering questions like "How much was spent today on the site?" and "What are the total number of goals scored by a particular team?"
To total up numeric columns use the SUM() function.
SELECT SUM(<numeric column) FROM <table>;
SELECT SUM(<numeric column) AS <alias> FROM <table>
GROUP BY <another column>
HAVING <alias> <operator> <value>;
Cheat Sheets
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
We're still working with
the e-commerce site database.
0:00
The CEO wants to reward the most
loyal customer with a gift card.
0:01
Let's find out which customer has
spent the most money on our site.
0:06
We're going to use the SUM function.
0:12
The SUM function sums up any numeric column.
0:15
It can be used by conjunction with
the GROUP BY keywords to calculate the sum
0:18
total of a column.
0:23
When you use the SUM
with a GROUP BY keywords,
0:25
you can generate total values
of differently grouped rows.
0:27
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up