1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| With MaTable AS
(
select 1 as id, 'Blue' as clr, 'Clear' as tnt, 'A11' as nom, 'Addidas' as mar from dual union all
select 2 , 'Blue' , 'Dark' , 'A22' , 'Nike' from dual union all
select 3 , 'Blue' , 'Dark' , 'A22' , 'Reebok' from dual union all
select 4 , 'Blue' , 'Dark' , 'A22' , 'New_Balance' from dual union all
select 5 , 'Red' , 'Clear' , 'A11' , 'Klein' from dual union all
select 6 , 'Red' , 'Dark' , 'A22' , 'Dolce' from dual
)
select MT1.id, MT1.clr, MT1.tnt, MT1.nom,
rtrim(replace(replace(xmlagg(xmlelement("x", mt2.mar)), '<x>', ''), '</x>', '-'), '-') as agg
from MaTable MT1
inner join MaTable MT2
on MT2.clr = MT1.clr
where MT1.nom = 'A11'
and MT2.nom = 'A22'
group by MT1.id, MT1.clr, MT1.tnt, MT1.nom
order by MT1.id asc;
ID CLR TNT NOM AGG
1 Blue Clear A11 Nike-Reebok-New_Balance
5 Red Clear A11 Dolce |
Partager