format_number
function
Applies to: Databricks SQL 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
: AnINTEGER
expression greater than or equal to 0.fmt
: ASTRING
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.-