

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
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
Sometimes we need to round some numbers, particularly when working with the results of an aggregation. We can use the ROUND() function to get the job done.
The SQL ROUND() function allows you to specify both the value you wish to round and the degree of precision to be applied:
ROUND(value, precision)
If no precision is given, SQL will round the value to the nearest whole value:
SELECT ROUND(AVG(song_length))
FROM songs;
This query returns the average song_length from the songs table, rounded to the nearest whole number.
If we do provide a precision, SQL will round to that many decimal places:
SELECT ROUND(AVG(song_length), 1)
FROM songs;
The same query, but rounded to a single decimal place.