我在oracle中运行以下查询。
WITH
ta AS (
SELECT account_coid
,txn_id
,cbdev.cbzdt(effective_date) AS effective_date
,cbdev.cbchr(utl_raw.substr(txn_data, 113, 20)) AS CESG_amt
FROM bs_transaction
WHERE sub_type = 127469880)
SELECT
cast(ta.CESG_amt as DECIMAL (20,2)) AS cesg_amt
from ta
inner join ....
在这里,我得到的结果(cesg_amt
)为-156.57
。但是我需要将结果作为-0000000000156.57
。
我需要保留-
的前导零(前导0和小数点后两位)。
我在查询中尝试使用to_char(ta.CESG_amt, '0000000000000.00') AS cesg_amt
,但没有用。
您能帮我在DECIMAL字段中进行以下操作以获得以下结果吗?
答案 0 :(得分:1)
您可以使用这种格式:
select to_char(-156.57,'fm0000000000000D00','NLS_NUMERIC_CHARACTERS = ''.,''')
as Result
from dual;
RESULT
-----------------
-0000000000156.57
答案 1 :(得分:0)
select to_char(-156.57,'000000000.00')
from dual;