Outdated Version

You are viewing an older version of this section. View current production version.

FORMAT

Rounds and formats a number with thousands separators and a fixed-length decimal part.

Syntax

FORMAT ( expression, precision )

Arguments

  • expression: any valid numeric expression.
  • precision: the number of digits after the decimal to pad or round to.

Return Type

String. The thousands separator is hard-coded to “,” and the decimal separator is “.”

Examples

select format(1234.565, 2);
+---------------------+
| format(1234.565, 2) |
+---------------------+
| 1,234.57            |
+---------------------+

select format(1234.56499, 2);
+------------------------+
| format(1234.561499, 2) |
+------------------------+
| 1,234.56               |
+------------------------+

select format(1234.567, 0);
+---------------------+
| format(1234.567, 0) |
+---------------------+
| 1,235               |
+---------------------+