Home > Database > SQL > body text

What does round mean in sql

下次还敢
Release: 2024-05-08 11:42:15
Original
1007 people have browsed it

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!