可能重複:
LISTAGG in oracle to return distinct values消除重複使用Oracle LISTAGG功能
我使用的是Oracle LISTAGG功能,但我回到名單之內我其實想消除重複,只有迴歸不同的值。
查詢我已經是這樣的:
select a.id,
a.change_id,
LISTAGG(b.name, ',') WITHIN GROUP (ORDER BY b.name) AS "Product Name",
from table_a a,
table_b b
where a.id = 1
and b.change_id = c.change_id
group by a.id, a.change_id
目前,它返回(只顯示一個記錄):
1 1 NameA, NameA, NameB, NameC, NameD, Name D
我想回的是:
1 1 NameA, NameB, NameC, Name D
希望有人能協助。
謝謝。
[LISTAGG在甲骨文可能重複返回不同的值](http://stackoverflow.com/questions/11510870/listagg-in-oracle-to-return-distinct-values),也在這裏http://dba.stackexchange.com/questions/696/eliminate -duplicates-in-listagg-oracle – 2012-07-24 05:20:31