在一列中显示金额字段

时间:2014-12-18 03:22:02

标签: sql oracle

我的数据如下

V1  01/01/2000  $5,000.00
V1  01/02/2001  $10,000.00

预期结果:

V1  5000.00/10,000.00

我使用listagg,输出结果为:

V1 5000/10000

逗号和比例(.00)丢失。如何使用listagg或任何其他方法显示金额字段?

1 个答案:

答案 0 :(得分:1)

试试这个:

with numbers as
(select 5000 num from dual
union all
select 10000 num from dual)
select listagg(to_char(num, 'fm9G999G999D00', 'NLS_NUMERIC_CHARACTERS = ''.,'''),'/')
       within group (order by num) "listing"
from numbers;