【发布时间】:2016-01-28 14:54:59
【问题描述】:
我是使用LISTAGG 函数的新手。当我运行以下脚本时,我收到一个无效的标识符错误:
ORA-00904: "TE"."COUNTRY": 标识符无效
有什么想法吗?
SELECT te.country, listagg(te.exception_date, ' ,') WITHIN GROUP (ORDER BY te.country) country
FROM
(select unique te.exception_date,
case when te.country is null then (select max(tt.country) from tt_transport tt where te.route = tt.route) else te.country end country
from tt_exception te
where trunc(te.exception_date) > '01-JAN-2015'
and te.plant = 'Z'
and not case when te.country is null then (select max(tt.country) from tt_transport tt where te.route = tt.route) else te.country end is null
order by te.country) te
group by te.country
UNION ALL
SELECT te.country, listagg(te.exception_date, ' ,') WITHIN GROUP (ORDER BY te.country) country
FROM
(select unique te.exception_date, 'GB' country
from tt_exception te
where trunc(te.exception_date) > '01-JAN-2015'
and te.plant = 'W'
and te.country is null
order by te.country)
group by te.country
【问题讨论】:
-
您使用的是什么版本的 Oracle?
-
LISTAGG函数只能在以下Oracle/PLSQL版本中使用:Oracle 12c, Oracle 11g Release 2
-
tt_exception表中是否有名为country的列?