我创建了一个带有连接列的视图。
我在各列上成功使用了listagg,但是当我尝试在listagg中使用连接列时,我收到错误,告知它是无效的标识符。
有没有办法以listagg格式组合需求和message_desc列?
我的查询如下:
select a.ID,
a.NAME,
a.YEAR,
count (a.linenum) as count_missing_docs,
listagg(a.requirement, ',') within group (order by a.requirement) as "reqs",
listagg(a.MESSAGE_DESC, '...')within group (order by a.MESSAGE_DESC)as "msgs",
listagg(a.combo,' ') within group (order by a.combo) as "all_info"
from
(SELECT
rownum "LINENUM",
FTR.ID,
FTR.NAME,
FTR.YEAR,
FTR.REQUIREMENT,
FTR.STATUS,
FTR.STATUS_IND,
FTR.MESSAGE_DESC,
FTR.REQUIREMENT||'-'||FTR.MESSAGE_DESC||'...' as "combo"
from TRACKING_REQUIREMENT FTR
where FTR.year = '1617'
and FTR.status = 'R'
and FTR.satisfied_ind = 'N'
order by 2 , 1 asc) A
group by
a.ID,
a.NAME,
a.YEAR
order by 1
答案 0 :(得分:3)
问题实际上只是你不断在你的标识符周围添加双引号 - 这告诉oracle你想要一个区分大小写的标识符,但是你在没有双引号的情况下引用它,使用一个不区分大小写的标识符(Oracle似乎在内部将其解释为ALL UPPERCASE)。
只需删除所有双引号,您的查询就可以正常工作。