PostgreSQL/Data Type/Cast

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

Cast char as integer

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



round(

postgres=# SELECT round(4.0, 4);
 round
--------
 4.0000
(1 row)
postgres=#



round(CAST (4 AS numeric), 4)

postgres=# SELECT round(CAST (4 AS numeric), 4);
 round
--------
 4.0000
(1 row)
postgres=#



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

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