数値型を次の形式の文字列に変換したい:
number -> string
1 -> 001
2 -> 002
12 -> 012
340 -> 340
TO_CHAR() (この状況では望ましい) 関数またはLPAD()関数のいずれかを使用して、目的の結果を得ることができます。
SQL> with t1(col) as(
2 select 1 from dual union all
3 select 2 from dual union all
4 select 12 from dual union all
5 select 340 from dual
6 )
7 select to_char(col, '000') as num_1
8 , lpad(to_char(col), 3, '0') as num_2
9 from t1
10 ;
NUM_1 NUM_2
----- ------------
001 001
002 002
012 012
340 340