PostgreSQL/Data Type/Cast

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

Cast char as integer

   <source lang="sql">

postgres=# postgres=# postgres=# SELECT 1 + CAST("1" || "2" AS integer) AS add_on_to_twelve;

add_on_to_twelve

              13

(1 row) postgres=#

      </source>
   
  


round(

   <source lang="sql">

postgres=# SELECT round(4.0, 4);

round

4.0000

(1 row) postgres=#

      </source>
   
  


round(CAST (4 AS numeric), 4)

   <source lang="sql">

postgres=# SELECT round(CAST (4 AS numeric), 4);

round

4.0000

(1 row) postgres=#

      </source>
   
  


SELECT 1 + ("1" || "2")::integer

   <source lang="sql">

postgres=# postgres=# postgres=# SELECT 1 + ("1" || "2")::integer AS add_one_to_twelve;

add_one_to_twelve

               13

(1 row) postgres=#

      </source>