From the course: SQL for Non-Programmers

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Making aggregate functions work for you

Making aggregate functions work for you - SQL Tutorial

From the course: SQL for Non-Programmers

Making aggregate functions work for you

Aggregate functions allow us to perform calculations over our data. The aggregate function count is used to count the number of rows in a table, or in a selected subset of the data. Moving beyond count, though, we can use the other aggregate functions sum, average, min, and max to perform calculations that reveal useful insights about our numerical data. We can pull summary statistics in just a couple lines of code. Let's hop back over to SLS. Management would like a summary report that shows the total sales and the average order value. Using the exact same syntax that we practiced with count, we can apply the same logic using the sum function. Sum is used to calculate the sum of all numeric values in a column. Going to our SQL editor, we can type, SELECT SUM order total as sum of orders. Remember, we can use the as keyword to assign an alias to the column. We'll go to the next line and add from oliveoil.sales. when we execute, we see that the total sales are over 1.6 million. What…

Contents