Share an SQL function, which can control the display of the decimal places of the query results. If you need it, please refer to it.
Share an SQL function, which can control the display of the decimal places of the query results. If you need it, please refer to it.
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: |
|
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 |