Copy Code code as follows:
SELECT FORMAT (12562.6655,2);
Result: 12,562.67
Viewing documents: Formats The number X to a format like ' #,###,###.## ', rounded to D decimal places, and returns the result as a string . If D is 0, the results has no decimal point or fractional parts more than three digits are separated by commas and the result returned is of type string.
Copy Code code as follows:
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, the desired results are not separated by commas,
Copy Code code as follows:
Select truncate (4545.1366,2);
Result: 4545.13, the direct interception is not rounded, still have the problem.
Copy Code code as follows:
Select CONVERT (4545.1366,decimal);
Results: 4545.14, to reach the expected.