From the course: SQL for Non-Programmers
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Getting started with aggregate functions6m 59s
-
(Locked)
Making aggregate functions work for you5m 35s
-
(Locked)
Group data using GROUP BY6m 26s
-
(Locked)
Filter on groups of data with HAVING4m 36s
-
(Locked)
Challenge: Practice with aggregate functions1m 38s
-
(Locked)
Solution: Aggregate functions solved5m 6s
-
-
-
-