TO_NUMERIC

functionsupportedCore SQL functions

docs.snowflake.com ↗

Conversion functions

Converts an input expression to a fixed-point number. These functions are synonymous.

Syntax

supportedpartialnot supportednot scored

TO_DECIMAL( <expr> [, '<format>' ] [, <precision> [, <scale> ] ] )

TO_NUMBER( <expr> [, '<format>' ] [, <precision> [, <scale> ] ] )

TO_NUMERIC( <expr> [, '<format>' ] [, <precision> [, <scale> ] ] )

Parameters

NameRequiredDescription
exprrequiredAn expression of a numeric, character, or variant type.
formatoptionalThe SQL format model used to parse the input expr and return. For more information, see SQL format models.
precisionoptionalThe maximum number of decimal digits in the resulting number, from 1 to 38. In Snowflake, precision isn’t used to determine the number of bytes that are needed to store the number and doesn’t have any effect on efficiency, so the default is the maximum (38).
scaleoptionalThe number of fractional decimal digits (from 0 to precision - 1). 0 indicates no fractional digits; that is, an integer number. The default scale is 0.

Returns

The function returns a value of type NUMBER with the following defaults: - If the precision isn’t specified, then it defaults to 38. - If the scale isn’t specified, then it defaults to 0. For NULL input, returns NULL.

Usage notes

See also