使用 TO_CHAR 返回哈希字符将数字字段格式化为货币

Formatting Number Field to Currency Using TO_CHAR returning hash characters

我正在 运行在 Oracle 数据库的 NUMBER 字段上进行简单的求和并转换为货币。

我的查询是:

select 
TO_CHAR(eve.data_entry_date, 'yyyy-mm'), wtc.description as WORK_TYPE,
TO_CHAR(sum(sev.amount),'9,999.99') AS "Total Invoice Amount"

from
EVENT eve,
SOW_EVENT sev,
WORK_TYPE_CODE wtc, 
SOW_WORK_TYPE_XREF swt,
WORK_TYPE_ITEM_CODE wti

where 
eve.event_number_id = sev.event_number_id
and sev.WORK_TYPE_CODE = WORK_TYPE_CODE
and sev.event_number_id = swt.event_number_id

group by 
TO_CHAR(eve.data_entry_date, 'yyyy-mm'), wtc.description

查询 运行 成功,但是 "Total Invoice Amount" 列中显示的金额返回的哈希值如下:

Year-Month   WORK_TYPE         Total Invoice AMount
2019-01      Physical Work     ############
2019-01      Technical Work    ############

我原以为我只需要调整列的大小,但那没有用。当我只是 运行:

sum(sev.amount)

它填充金额,只是没有格式化为货币,因为 'amount' 列是数字列。知道为什么我在格式化为货币时得到哈希值吗?

From the documentation:

All number format models cause the number to be rounded to the specified number of significant digits. If a value has more significant digits to the left of the decimal place than are specified in the format, then pound signs (#) replace the value. This event typically occurs when you are using TO_CHAR with a restrictive number format string, causing a rounding operation.

您的格式掩码需要足够的数字占位符才能显示您希望看到的最高值。目前的价值似乎超过一百万。