Penso che per far funzionare la tua query, devi aggiungere un group by
, cambia order by
. Dovresti anche usare la sintassi di join esplicita corretta:
SELECT r.rule_id as RULE_ID,
LISTAGG(a.ATTRIBUTE_ID, ', ') WITHIN GROUP (ORDER BY a.ATTRIBUTE_ID) as "ATTR_IDS"
FROM N_RULE r JOIN
N_ATTRIBUTE a
ON r.RULE_ID = a.RULE_ID
GROUP BY r.rule_id
ORDER BY r.rule_id;
Oppure, possibilmente vuoi includere un altro attributo nei risultati:
SELECT r.rule_id, r.AUDIENCE, UPPER(r.NAME)
LISTAGG(a.ATTRIBUTE_ID, ', ') WITHIN GROUP (ORDER BY a.ATTRIBUTE_ID) as "ATTR_IDS"
FROM N_RULE r JOIN
N_ATTRIBUTE a
ON r.RULE_ID = a.RULE_ID
GROUP BY r.rule_id, r.AUDIENCE, UPPER(r.NAME)
ORDER BY r.AUDIENCE, UPPER(r.NAME);