Rounding floating point data in SQL Server

Source: Internet
Author: User
In this report, it is found that the report calculation results are different from the data in the customer's original report. because the other party has strict requirements on data accuracy, the report is not sloppy. After multiple comparisons, it is found that the original report calculation uses 4-bit precision, while the current quote calculation uses the float data type. The 15-bit precision produces some differences in the results. The subsequent business volume is determined to be consistent with the customer's original system, and the 4-bit precision calculation is adopted. In SQL Server, the round () function can be used for rounding float data types. Because the result uses a calculated expression, an infinite number of loops is generated in the result. directly using the round () function cannot be used for rounding, you must first convert the float data type to the numeric data type, and then perform the round () rounding operation to get the correct result. It seems that the float data type must be considered at multiple layers in SQL Server.
Select GLD, round (convert (Numeric (6, 3), ejgyjfbz), 2), round (convert (Numeric (6, 3), sjgyjfbz), 2) from GLD
Related Article

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.