- Categories:
AS_DOUBLE , AS_REAL¶
Casts a VARIANT value to a floating-point value.
AS_REAL is a synonym for AS_DOUBLE.
- See also:
Syntax¶
AS_DOUBLE( <variant> )
AS_REAL( <variant> )
Arguments¶
variant
This should be an expression that evaluates to a VARIANT that contains a valid floating-point value.
Examples¶
Here is a valid (although inefficient) way to calculate the area of a circle with radius 2 by using the AS_DOUBLE() function:
Create and fill a table:
CREATE TABLE demo (radius DOUBLE, v_radius VARIANT); INSERT INTO demo (radius) VALUES (2.0); UPDATE demo SET v_radius = TO_VARIANT(radius);Query the table:
SELECT pi() * AS_DOUBLE(v_radius) * AS_DOUBLE(v_radius) AS area1, pi() * radius * radius AS area2 FROM demo; +--------------+--------------+ | AREA1 | AREA2 | |--------------+--------------| | 12.566370614 | 12.566370614 | +--------------+--------------+