Home  >  Article  >  Database  >  What does round mean in sql

What does round mean in sql

下次还敢
下次还敢Original
2024-05-08 11:42:151009browse

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>

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>

Output:

<code>123.46</code>

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn