FORMAT Formats a number to a format like "#,###,###.##", rounded to a specified number of decimal places
SELECT FORMAT(432178.976, 0);
98.9
99
98.4
98
3,427,498,237,498,723.649
9 rows in set (0.001 sec)
MariaDB [vlrinst]> select format(998679.86123,0);
+------------------------+
| format(998679.86123,0) |
+------------------------+
| 998,680 |
+------------------------+
1 row in set (0.001 sec)
MariaDB [vlrinst]> select format(998676.86123,0);
+------------------------+
| format(998676.86123,0) |
+------------------------+
| 998,677 |
+------------------------+
1 row in set (0.000 sec)
MariaDB [vlrinst]> select format(998676.46123,0);
+------------------------+
| format(998676.46123,0) |
+------------------------+
| 998,676 |
+------------------------+
1 row in set (0.000 sec)
MariaDB [vlrinst]> select format(998676.46123,1);
+------------------------+
| format(998676.46123,1) |
+------------------------+
| 998,676.5 |
+------------------------+
1 row in set (0.001 sec)
MariaDB [vlrinst]> select format(998676.46123,3;
ERROR 1064 (42000): You have an error in your SQL syntax; ch
MariaDB [vlrinst]> select format(998676.46123,3);
+------------------------+
| format(998676.46123,3) |
+------------------------+
| 998,676.461 |
+------------------------+
1 row in set (0.001 sec)
MariaDB [vlrinst]> select format(998676.46123,3);
+------------------------+
| format(998676.46123,3) |
+------------------------+
| 998,676.461 |
+------------------------+
1 row in set (0.001 sec)
MariaDB [vlrinst]> select fromat(749234792834792374.6712821,
ERROR 1305 (42000): FUNCTION vlrinst.fromat does not exist
MariaDB [vlrinst]> select format(749234792834792374.6712821,
+--------------------------------------+
| format(749234792834792374.6712821,0) |
+--------------------------------------+
| 749,234,792,834,792,375 |
+--------------------------------------+
1 row in set (0.001 sec)
MariaDB [vlrinst]> select format(749234792834792374.4712821,
+--------------------------------------+
| format(749234792834792374.4712821,0) |
+--------------------------------------+
| 749,234,792,834,792,374 |
+--------------------------------------+
1 row in set (0.000 sec)
MariaDB [vlrinst]> select format(749234792834792374.4712821,
+--------------------------------------+
| format(749234792834792374.4712821,1) |
+--------------------------------------+
| 749,234,792,834,792,374.5 |
+--------------------------------------+
1 row in set (0.000 sec)
MariaDB [vlrinst]> select format(749234792834792374.4712821,
+--------------------------------------+
| format(749234792834792374.4712821,2) |
+--------------------------------------+
| 749,234,792,834,792,374.47 |
+--------------------------------------+
1 row in set (0.001 sec)
MariaDB [vlrinst]> select format(749234792834792374.47,2);
+---------------------------------+
| format(749234792834792374.47,2) |
+---------------------------------+
| 749,234,792,834,792,374.47 |
+---------------------------------+
1 row in set (0.000 sec)
MariaDB [vlrinst]> select format(749234792834792374.475,2);
+----------------------------------+
| format(749234792834792374.475,2) |
+----------------------------------+
| 749,234,792,834,792,374.48 |
+----------------------------------+
1 row in set (0.000 sec)
MariaDB [vlrinst]> select format(749234792834792374.475,1);
+----------------------------------+
| format(749234792834792374.475,1) |
+----------------------------------+
| 749,234,792,834,792,374.5 |
+----------------------------------+
1 row in set (0.000 sec)
MariaDB [vlrinst]> select format(sal,0) from emp;;
+---------------+
| format(sal,0) |
+---------------+
| 30,000 |
| 35,000 |
| 39,000 |
| 20,000 |
| 20,000 |
| 30,100 |
| 100 |
| 30,300 |
| 39,300 |
+---------------+
9 rows in set (0.001 sec)
ERROR: No query specified
MariaDB [vlrinst]> select format(749234792834792374,1);
+------------------------------+
| format(749234792834792374,1) |
+------------------------------+
| 749,234,792,834,792,374.0 |
+------------------------------+
1 row in set (0.001 sec)
MariaDB [vlrinst]> select format(749234792834792374,0);
+------------------------------+
| format(749234792834792374,0) |
+------------------------------+
| 749,234,792,834,792,374 |
+------------------------------+
1 row in set (0.001 sec)
MariaDB [vlrinst]> select format(749234792834792374,4);
+------------------------------+
| format(749234792834792374,4) |
+------------------------------+
| 749,234,792,834,792,374.0000 |
+------------------------------+
1 row in set (0.000 sec)
MariaDB [vlrinst]>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.