

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
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
Just like we may want to find the minimum or maximum values within a dataset, sometimes we need to know the average!
SQL offers us the AVG() function. Similar to MAX(), AVG() calculates the average of all non-NULL values.
SELECT AVG(song_length)
FROM songs;
This query returns the average song_length in the songs table.
Our marketing team is trying to determine the best marketing channels to advertise through, but they need more information about our current users. They want to know the average age of users in the United States.
Return a single value representing the average age of all users whose country_code is US.