在Oracle中转换为十进制时如何保留前导零

编程入门 行业动态 更新时间:2024-10-18 03:37:20
本文介绍了在Oracle中转换为十进制时如何保留前导零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在oracle中运行以下查询.

I am running the below query in 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和小数点后两位).

Here, i m getting the result (cesg_amt) as -156.57. But i need the result as -0000000000156.57. I need the leading zeros with - retained (leading 0's and also the two digits after the decimal).

我在查询中尝试使用to_char(ta.CESG_amt, '0000000000000.00') AS cesg_amt,但没有用.

I have tried as to_char(ta.CESG_amt, '0000000000000.00') AS cesg_amt in the query but of no use.

您能帮我在DECIMAL字段中进行以下操作以获得以下结果吗?

Can you please help me what needs to be done in the DECIMAL field to get the result as below.

推荐答案

您可以使用这种格式:

select to_char(-156.57,'fm0000000000000D00','NLS_NUMERIC_CHARACTERS = ''.,''') as Result from dual; RESULT ----------------- -0000000000156.57

更多推荐

在Oracle中转换为十进制时如何保留前导零

本文发布于:2023-10-24 20:07:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524880.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:前导   转换为   Oracle   十进制时

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!