Kombinace xmlagg a xQuery, to není jednoduché.
select xmlquery('distinct-values(//text())' passing x returning content).getclobVal(),data_type from (
select xmlelement(root, xmlagg(XMLELEMENT(e,table_name,','))) x ,data_type
from user_tab_cols where data_type in ('VARCHAR2','NUMBER')
group by data_type
)
A pro vaše účely by to mělo vypadat takto
select
app, key_event,
xmlquery('distinct-values(//text())' passing xmldoc returning content).getclobVal()
from
(select
t2.app,
coalesce(max(case when language = 2 then description end),
max(case when language = 12 then description end),
max(case when language = 27 then description end),
'NULL') key_event,
XMLELEMENT(root, xmlagg(XMLELEMENT(e, description, ','))
) xmldoc
from
table2 t2
left join
table1 t1 on t1.app = t2.app
group by
trans, t2.app
order by trans);
pokud tento dotaz rozložíte, uvidíte, jak funguje.
syntaxe odlišných hodnot xquery