The problem of formatting the floating-point number, using Format (col,2) to retain the two-bit decimal point, there is a problem, such as the following statement, after we give a workaround
SELECT FORMAT (12562.6655,2);
Results: 12,562.67
View Document: Formats The number X to a format like ' #,###,###.## ', rounded to D decimal places, and returns the result as a string . If D is 0 and the result has a no decimal point or a fractional part that is more than three bits long with a comma, and the result returned is of type string.
Mysql> Select Format (12332.123456, 4);-> ' 12,332.1235 ' mysql> Select Format (12332.1,4);-> ' 12,332.1000 ' Mysql> SELECT FORMAT (12332.2,0);-> ' 12,332 '
Do not achieve the expected results, do not want the results separated by commas,
Select truncate (4545.1366,2);
Results: 4545.13, direct interception does not round, or there is a problem.
Select CONVERT (4545.1366,decimal);
Results: 4545.14, reached the expected.
Add: Convert cannot be rounded to reach the message, and convert has the same effect as truncate, intercepting two digits after the decimal point.
Rounding retains two digits after decimal point: ROUND (x,d)
Select ROUND (4545.1366,2);
Results: 4545.15, reached the expected.
MySQL formatted decimal two digits after decimal (decimal point formatting)