MySQL round function

Source: Internet
Author: User

In MySQL, the round function is used for rounding data, which has two forms:

1, round (x,d), x refers to the number to be processed, d refers to the retention of several decimals

One of the notable points here is that D can be a negative number, when the D-bit integer bit to the left of the specified decimal point is 0, and the decimal places are 0;

2, round (x), is actually round (x,0), also is the default d is 0;

Here are a few examples

1, query: Select round (1123.26723,2);

Results: 1123.27

2, query: Select round (1123.26723,1);

Results: 1123.3

3, query: Select round (1123.26723,0);

Results: 1123

4, query: Select round (1123.26723,-1);

Results: 1120

5, query: Select round (1123.26723,-2);

Results: 1100

5, query: Select round (1123.26723);

Results: 1123

MySQL round function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.