PostgreSQL/String Functions/to number

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

to_number("00123456789", "00999999999")

postgres=# SELECT to_number("00123456789", "00999999999")       AS leading_zeroes;
 leading_zeroes
----------------
      123456789
(1 row)
postgres=#



to_number("123,456,789.00", "999G999G999D99")

postgres=# SELECT to_number("123,456,789.00", "999G999G999D99") AS formatted;
  formatted
--------------
 123456789.00
(1 row)
postgres=#



to_number("123456789", "999999999")

postgres=# SELECT to_number("123456789", "999999999")           AS just_digits;
 just_digits
-------------
   123456789
(1 row)
postgres=#



to_number("$2,900.00", "L9G999D99")

postgres=# SELECT to_number("$2,900.00", "L9G999D99")
postgres-#           AS monetary;
 monetary
----------
  2900.00
(1 row)
postgres=#