How to convert oracle number type to string with format? -


i want convert number type string format as:

number -> string      1      -> 001     2      -> 002     12     -> 012     340    -> 340   

you can use either to_char() (preferable in situation) function or lpad() function achieve desired result:

sql> t1(col) as(   2    select 1   dual union   3    select 2   dual union   4    select 12  dual union   5    select 340 dual   6  )   7  select to_char(col, '000')        num_1   8       , lpad(to_char(col), 3, '0') num_2   9    t1  10  ;  num_1 num_2 ----- ------------  001  001  002  002  012  012  340  340 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -