Oracle sql: Using two listagg -


i'm using following code bring through 'del' text , 'pal' text. 'del' , 'pal' text across several lines (and not same amount of lines of each).

select trim(listagg(tx1.text, ', ') within group (order tx1.text)) del_text, trim(listagg(tx2.text, ', ') within group (order tx2.text)) pal_text oes_ordtxt tx1 inner join oes_ordtxt tx2     on tx1.key1 = tx2.key1     , tx1.key2 = tx2.key2     , tx1.key3 = tx2.key3     , tx2.doctyp = 'pal' tx1.key1 = '0018104834' , tx1.key2 = '00001' , tx1.key3 = '001' , tx1.doctyp = 'del' 

the problem have have multiple rows on 'del text , 1 row on 'pal' text 'pal' text repeats, e.g.

enter image description here

the 'pal_text' duplicating 1 pal_text exists but, 3 del_text exists.

is there way remove duplicates?

thanks, smorf

it doesn't matter how many tables in aggregation (unfortunately can't check syntax without data structure):

select (select listagg(column_value,', ') within group (order column_value) table (del_text)) del_text       ,(select listagg(column_value,', ') within group (order column_value) table (pal_text)) pal_text (select collect (distinct tx1.text) del_text,              collect (distinct tx2.text) pal_text       oes_ordtxt tx1       inner join oes_ordtxt tx2          on tx1.key1 = tx2.key1         , tx1.key2 = tx2.key2         , tx1.key3 = tx2.key3         , tx2.doctyp = 'pal'       tx1.key1 = '0018104834'         , tx1.key2 = '00001'         , tx1.key3 = '001'         , tx1.doctyp = 'del'       group 1) 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -