The ROUND command rounds a value to the nearest integer or to a specific number of decimals if an optional value is provided.


ROUND(value, decimal_places)

If the optional decimal_places parameter is omitted, then the value is rounded with zero decimals.


The example below assumes there is a grades table with a column test_scores with values for all the exams administered in a semester, rounded to two decimal places:

SELECT names,
ROUND(AVG(test_scores), 2)) AS semster_avg
FROM grades
GROUP BY names;


Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn SQL on Codecademy