concat multiple output lines
975565Nov 21 2012 — edited Nov 26 2012Hi all,
I'm struggling with a problem for quite a while now and can't find any solution online so far ...
OK I got three different Tables
cust_tbl:
customer:id
nuxx :1
naxx :2
baxx :3
suxx :4
parts_tbl:
part_nr : amount : id
x201 : 100 : 11
ds32 : 100 : 12
ddd11 : 200 : 13
lkj1 : 250 : 14
order_tbl:
cust_id : part_id : address
1 : 11 : aaa
1 : 11 : bbb
1 : 12 : ccc
2 : 11 : ddd
2 : 14 : eee
3 : 13 : fff
4 : 12 : ggg
Now, what I need is an output like this:
Customer, part1, amount1, address1,part2, amount2, addess2, ...
e.g.
nuxx:x201-100-aaa,x201-100-bbb,ds32-100-fff
naxx:201-100-aaa,lkj1-250-ggg
baxx:ddd11-200-fff
suxx:ds32-100-ggg
As you see, I only need the Customer one time followed by part, amount and address - separated hyphen - comma, next part, amount, address and so on ...
I've tried the PIVOT way and STRAGG (wm_concat) but all failed so far.
The main problem is that when one customer fits more than one condition, ora throws: ORA-01427: single-row subquery returns more than one row
Any ideas ?