0

我在一个简单的查询中有 ora-00094(标识符无效),但我不明白为什么。请问你能帮帮我吗?

select columnA, 'More than 4000 bytes'
from tableA

union all

select  p.columnB, listagg(p.columnC, ',') within group (order by p.columnC)
from (            
  select distinct b.job_name, a.hostname
  from tableB a, emuser.def_job b
) p   
group by p.columnB 
order by p.columnB desc;
4

1 回答 1

1

ORDER BY 用于整个查询的 ResultSet。所以对于 ORDER BY,这里没有 columnB。结果集只有第一个查询的列名。

尝试这个

SELECT columnA, 'More than 4000 bytes' as columnC  FROM tableA
UNION ALL
  SELECT p.columnB, LISTAGG (p.columnC, ',') WITHIN GROUP (ORDER BY p.columnC)
    FROM (SELECT DISTINCT b.job_name, a.hostname
            FROM tableB a, emuser.def_job b) p
GROUP BY p.columnB
ORDER BY p.columnA DESC;
于 2017-11-21T08:07:09.700 回答