0
Hello, everybody. Good afternoon.
I have a query that concatenated several record using a certain key.
However it brings some repeated values as a result. Below an example of a query:
SELECT PEH.PN,
LISTAGG (PEH.AC_TYPE, ',') WITHIN GROUP (ORDER BY PEH.AC_TYPE DESC) AS
"EFETIVIDADE"
FROM
ODB.PN_EFFECTIVITY_HEADER PEH
GROUP BY PEH.PN;
Which brings as a result:
PN | Efetividade
39 | E190,E190
41 | E170
42 | E190,E190
43 | ATR42
44 | ATR72,ATR72
In case you need it not to repeat equal values (Like E190, for example).
How I Treat These Incidences in Oracle Developer?
Thank you very much.
Hi, Luan, hello, Luan! First I would advise you to do the query without the listagg, there should probably be duplicate values, so you would have to treat in your query not to repeat these values. Simulating the above problem: http://sqlfiddle.com/#! 4/74fa1/3/0
– Confundir
Hello, friend. In the table the values were not duplicated. I checked before doing the LISTAGG. The friend solution below creating a virtual table worked! Thank you so much for your contribution! Hug!!
– LuanMatos