FORMAT()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns a formatted number rounded to the specified number of decimal places.
USAGE
FORMAT(number, count)
Argument Name | Description |
---|---|
| The number to format |
| The number of decimal places to include in the result |
DETAILS
FORMAT()
is a string function that returns a formatted number that is rounded to the specified number of decimal places.
The return value is formatted as #,###,###.##
.
The return value does not include a decimal point in the result if the requested number of decimal places is 0
.
A NULL
is returned if either argument is NULL
.
EXAMPLES
SELECT FORMAT(1, 1), FORMAT(12345.2, 4);
+--------------+--------------------+
| FORMAT(1, 1) | FORMAT(12345.2, 4) |
+--------------+--------------------+
| 1.0 | 12,345.2000 |
+--------------+--------------------+
SELECT FORMAT(1, 0), FORMAT(1234567.2, 2);
+--------------+----------------------+
| FORMAT(1, 0) | FORMAT(1234567.2, 2) |
+--------------+----------------------+
| 1 | 1,234,567.20 |
+--------------+----------------------+