我尝试将TOTAL_MONEY格式化为“123,456,789”(带逗号)。
select entity_id,
'the sum is:' || to_char(TOTAL_MONEY, ',') as text_msg
from(
select entity_id,
sum(volume) as TOTAL_MONEY
from procurement) t
但它不起作用。我没有发现here有用的东西。
你能帮帮我吗?
答案 0 :(得分:1)
select entity_id,
'the sum is:' || ltrim(rtrim(to_char(TOTAL_MONEY, '999,999,999,999'))) as text_msg
from(
select entity_id,
sum(volume) as TOTAL_MONEY
from procurement
) t
答案 1 :(得分:1)
又一个更简单的解决方案:
select
entity_id,
to_char(TOTAL_MONEY, '"the sum is: "FM999,999,999,999') as text_msg
from(
select entity_id, sum(volume) as TOTAL_MONEY
from procurement) t
有'FM'
选项可以删除不必要的空格; "double-quoted string"
按原样打印,不替换任何模式/占位符。