AS_NUMBER

functionsupportedCore SQL functions

docs.snowflake.com ↗

Semi-structured and structured data functions

Casts a VARIANT value to a fixed-point NUMBER value, with optional precision and scale. This function doesn’t cast floating-point values. AS_DECIMAL is a synonym for AS_NUMBER. The DECIMAL data type is synonymous with the NUMBER data type.

Syntax

supportedpartialnot supportednot scored

AS_DECIMAL( <variant_expr> [ , <precision> [ , <scale> ] ] )

AS_NUMBER( <variant_expr> [ , <precision> [ , <scale> ] ] )

Parameters

NameRequiredDescription
variant_exprrequiredAn expression that evaluates to a value of type VARIANT.
precisionrequiredThe number of significant digits of the decimal number to store. The default is 38.
scalerequiredThe number of significant digits after the decimal point. The default is 0.

Returns

The function returns a value of type NUMBER or NULL: - If the type of the value in the variant_expr argument is DECIMAL or NUMBER, the function returns a value of type NUMBER. - If the type of the value in the variant_expr argument doesn’t match the type of the output value, the function returns NULL. - If the variant_expr argument is NULL, the function returns NULL.

Usage notes

See also