SQL decimal control query output decimal places

Source: Internet
Author: User
Tags numeric

Decimal (18,0)
18 indicates the precision of the specified point, and 0 indicates the number of decimal places.
Decimal (a, B)
A specifies the maximum number of decimal digits that can be stored on the left and right of the decimal point. The maximum precision is 38.
B specifies the maximum number of decimal digits that can be stored on the right of the decimal point. The number of decimal places must be between 0 and. The default number of decimal places is 0.

Instance

The code is as follows: Copy code

Select cast (12.347343 asdecimal ))

Output

12.35

 

Decimal [ ( P[ , S] )] And numeric [ ( P[ , S] )]

Fixed precision and decimal places. When the maximum precision is used, the valid values are from-10 ^ 38 + 1 to 10 ^ 38-1. The ISO synonyms of decimal are dec and dec (P, S). Numeric is functionally equivalent to decimal.

P (precision)

The total number of digits that can be stored at most, including the digits on the left and right of the decimal point. The precision must be between 1 and 38. The default precision is 18.

S(Decimal places)

The maximum number of digits that can be stored on the right of the decimal point. The number of decimal places must be from 0P. The number of decimal places can be specified only after the precision is specified. The default number of decimal places is 0. Therefore, 0 <=S<=P. The maximum storage size varies based on precision.

 

Precision

Storage bytes

1-9

5

10-19

9

20-28

13

29-38

17

 

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.