别名 table with union all 不起作用
alias table with union all not works
我在一个简单的查询中有 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;
ORDER BY 用于整个查询的结果集。所以对于 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;
我在一个简单的查询中有 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;
ORDER BY 用于整个查询的结果集。所以对于 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;