FORMAT
Declaration
FORMAT(X,D)
Description
Converts the number X from the #,###,###.## format to the #,###,###.## format, rounds it to D decimal places, and returns the result as a string.
If the integer part exceeds three digits, a comma (,) is used as the thousand separator.
If D is 0, the result does not include a decimal point or decimal part.
Example
SELECT FORMAT(12332.123456, 4) FROM DUAL;
+-------------------------+
| format(12332.123456, 4) |
+-------------------------+
| 12,332.1235 |
+-------------------------+
1 row in set (0.001 sec)
SELECT FORMAT(12332.1, 4) FROM DUAL;
+--------------------+
| format(12332.1, 4) |
+--------------------+
| 12,332.1000 |
+--------------------+
1 row in set (0.001 sec)
SELECT FORMAT(12332.2, 0) FROM DUAL;
+--------------------+
| format(12332.2, 0) |
+--------------------+
| 12,332 |
+--------------------+
1 row in set (0.000 sec)