PostgreSQL/Math Functions/PI

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

pi() constant

   <source lang="sql">

postgres=# -- pi() constant postgres=# select pi();

       pi

3.14159265358979

(1 row) postgres=#

      </source>
   
  


pi(): Returns the pi constant (3.14159...)

   <source lang="sql">

postgres=# -- pi(): Returns the pi constant (3.14159...) postgres=# postgres=# SELECT pi() AS "the pi constant";

the pi constant

3.14159265358979

(1 row) postgres=#

      </source>
   
  


Use pi() in calculation

   <source lang="sql">

postgres=# postgres=# SELECT 2 + 2 AS "2 plus 2", pi() AS "the pi function", "PostgreSQL is more than a calculator!" AS comments;

2 plus 2 | the pi function  |               comments

+------------------+---------------------------------------
       4 | 3.14159265358979 | PostgreSQL is more than a calculator!

(1 row) postgres=# postgres=#

      </source>