WITH t AS ( SELECT 123456789012345 amt FROM dual UNION ALL SELECT 29000 FROM dual UNION ALL SELECT 20000 FROM dual UNION ALL SELECT 309840 FROM dual UNION ALL SELECT 200000000 FROM dual ) SELECT amt , DECODE(a1, 0, '', a1 || '조') || DECODE(a2, 0, '', a2 || '억') || DECODE(a3, 0, '', a3 || '만') || DECODE(a4, 0, '', a4)|| '원' v FROM (SELECT amt , FLOOR(amt / 1000000000000) a1 , FLOOR(MOD(amt, 1000000000000) / 100000000) a2 , FLOOR(MOD(amt, 100000000) / 10000) a3 , MOD(amt, 10000) a4 FROM t ) ; -- http://gurubee.net/lecture/2224