A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/functions/to_double below:

Website Navigation


TO_DOUBLE | Snowflake Documentation

Categories:

Conversion functions

TO_DOUBLE

Converts an expression to a double-precision floating-point number.

For NULL input, the result is NULL.

See also:

TRY_TO_DOUBLE

Syntax
TO_DOUBLE( <expr> [, '<format>' ] )

Copy

Arguments
expr

An expression of a numeric, character, or variant type.

format

If the expression evaluates to a string, then the function accepts an optional format model. Format models are described at SQL format models. The format model specifies the format of the input string, not the format of the output value.

Returns

This function returns a value of FLOAT data type.

If expr is NULL, the function returns NULL.

Usage notes Examples

After creating a table with columns of different data types, this script calls TO_DOUBLE on each of those columns:

CREATE OR REPLACE TABLE double_demo (d DECIMAL(7, 2), v VARCHAR, o VARIANT);
INSERT INTO double_demo (d, v, o) SELECT 1.1, '2.2', TO_VARIANT(3.14);
SELECT TO_DOUBLE(d), TO_DOUBLE(v), TO_DOUBLE(o) FROM double_demo;

Copy

+--------------+--------------+--------------+
| TO_DOUBLE(D) | TO_DOUBLE(V) | TO_DOUBLE(O) |
|--------------+--------------+--------------|
|          1.1 |          2.2 |         3.14 |
+--------------+--------------+--------------+

The following example shows that converting from a binary float back to a number is not precise:

SELECT TO_DOUBLE(1.1)::NUMBER(38, 18);

Copy

+--------------------------------+
| TO_DOUBLE(1.1)::NUMBER(38, 18) |
|--------------------------------|
|           1.100000000000000089 |
+--------------------------------+

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4