format_number function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Formats expr like #,###,###.##, rounded to scale decimal places.

Formats expr like fmt.

Syntax

format_number(expr, scale)
format_number(expr, fmt)

Arguments

  • expr: An expression that evaluates to a numeric.
  • scale: An INTEGER expression greater than or equal to 0.
  • fmt: A STRING expression specifying a format.

Returns

A STRING.

A negative scale produces a null.

Examples

> SELECT format_number(12332.123456, 4);
 12,332.1235

> SELECT format_number(12332.123456, '#.###');
 12332.123

> SELECT format_number(12332.123456, 'EUR ,###.-');
 EUR 12,332.-