SQL ROUND Function
SQL > SQL Functions >
The ROUND function in SQL is used to round a number to a specified precision.
The syntax for the ROUND function is,
ROUND (expression, [decimal place])
where [decimal place] indicates the number of decimal points returned. A negative number means the rounding will occur to a digit to the left of the decimal point. For example, -1 means the number will be rounded to the nearest tens.
We use the following table for our examples.
and this table contains the following rows:
Example 1: Decimal place is positive
To round to the nearest tenths place, we use the following SQL:
SELECT First_Name, ROUND (Rating, 1) Rounded_Score FROM Student_Rating;
Example 2: Decimal place is negative
To round to the nearest tens place, we use the following SQL:
SELECT First_Name, ROUND (Rating, -1) Rounded_Score FROM Student_Rating;