PostgreSQL/Math Functions/Power

Материал из SQL эксперт
Перейти к: навигация, поиск

CAST(2 AS double precision) ^ CAST(3 AS double precision)

postgres=# SELECT CAST(2 AS double precision) ^ CAST(3 AS double precision) AS "exp";
 exp
-----
   8
(1 row)
postgres=#



power(a dp, b dp) a raised to the power of b

postgres=# --power(a dp, b dp) a raised to the power of b
postgres=# select power(9.0, 3.0);
        power
----------------------
 729.0000000000000000
(1 row)
postgres=#



power(a numeric, b numeric) numeric a raised to the power of b

postgres=# -- power(a numeric, b numeric) numeric a raised to the power of b
postgres=#
postgres=# select power(9.0, 3.0);
        power
----------------------
 729.0000000000000000
(1 row)
postgres=#



Power operator

postgres=# SELECT 2 ^ 3 AS "exp";
 exp
-----
   8
(1 row)
postgres=#