Description
The FORMAT( ) function formats the number X in the format “#,###,###.##”, which is rounded to decimal places (D), and returns as a string.
This function has the form:
SELECT FORMAT(x, D)
Parameter | Description |
---|---|
x | A number |
D | Decimal places |
Return Value
Formats the number X in the format “#,###,###.##”, which is rounded to decimal places (D), and returns as a string.
Examples
The following example shows the basic use of this function:
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'
mysql> SELECT FORMAT(12332.2,2,'de_DE');
-> '12.332,20'