ROUND

Published Oct 7, 2022Updated Mar 25, 2023
Contribute to Docs

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

Syntax

ROUND(value, decimal_places)

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

Example

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 semester_avg
FROM grades
GROUP BY names;

All contributors

Looking to contribute?

Learn SQL on Codecademy