i am new to PostgreSQL.i want to convert string '0480' to number 0480 .i am using casting operator to do this,
db=# select '0480':: numeric;
numeric
---------
480
(1 row)
but here I am expecting 0480 number. Then i tried to_number function in PostgreSQL,
db=# select to_number('0480','9999');
to_number
-----------
480
(1 row)
so how is this possible? how can I convert number strings with leading zeros to numeric value with leading zero.
also some outputs of to_char function, little bit confusing?
db=# select to_char(0480,'9999');
to_char
---------
480
(1 row)
db=# select to_char(0480,'09999');
to_char
---------
00480
(1 row)
Using PostgreSQL 12.3 on Debian