Starting here? This lesson is part of a full-length tutorial in using SQL for Data Analysis. Check out the beginning.
The query below selects the sum of the
volume column from the Apple stock prices dataset:
SELECT SUM(volume) FROM tutorial.aapl_historical_stock_price
An important thing to remember: aggregators only aggregate vertically. If you want to perform a calculation across rows, you would do this with simple arithmetic.
You don't need to worry as much about the presence of nulls with
SUM as you would with
SUM treats nulls as 0.