ROUND meaning in SQL
In SQL, the ROUND function is used to round a number to a specified number of decimal places. This function rounds a number according to the specified number of digits and returns the result as output.
Syntax
<code>ROUND(number, decimal_places)</code>
Copy after login
Where:
-
number: The number to be rounded.
-
decimal_places: Specifies the number of decimal places to round to.
Example
To round the number 123.4567 to two decimal places, you can use the following query:
<code>SELECT ROUND(123.4567, 2);</code>
Copy after login
Output:
<code>123.46</code>
Copy after login
Rounding rules
ROUND function follows standard rounding rules:
- If the number after the rounding digit is greater than or equal to 5, then round The position increases by 1.
- If the number following the rounding digit is less than 5, the rounding digit remains unchanged.
Note
- If the specified number is NULL, the ROUND function returns NULL.
- If the specified decimal_places is a negative number, the ROUND function returns the input number itself (unrounded).
- If the specified decimal_places is greater than the number of decimal places of the input number, the ROUND function returns the input number directly.
The above is the detailed content of What does round mean in sql. For more information, please follow other related articles on the PHP Chinese website!