Copy codeThe Code is as follows:
Select format (12562.6655, 2 );
Result: 12,562.67
See the 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, the result has no decimal point or fractional part. when the integer part exceeds three digits, it is separated by commas and the returned result is of the string type.
Copy codeThe Code is as follows:
Mysql> select format (12332.123456, 4 );
-> '123'
Mysql> select format (12332.1, 4 );
-> '123'
Mysql> select format (12332.2, 0 );
-> '123'
If the expected results are not met, do not separate them with commas,
Copy codeThe Code is as follows:
Select truncate (4545.1366, 2 );
Result: There is still a problem when the screenshot is not rounded up.
Copy codeThe Code is as follows:
Select convert (4545.1366, decimal );
Result: 4545.14, as expected.