Hi,
with xx(ic, itn, siz, qty) as(
select 1, 'A', 'S', 5 from dual UNION ALL
select 1, 'A', 'S', 500 from dual UNION ALL -- "New row added. Id & Name are same in 2 rows"
select 2, 'B', 'S', 6 from dual UNION ALL
select 3, 'C', 'M', 6 from dual UNION ALL
select 4, 'D', 'L', 8 from dual UNION ALL
select 5, 'E', 'XL', null from dual
)
select
ic, itn,
max(decode(siz,'S',qty)) "S",
max(decode(siz,'M',qty)) "M",
max(decode(siz,'L',qty)) "L",
max(decode(siz,'XL',qty)) "XL"
from
xx
group by ic,itn
order by ic;
IC I S M L XL
---------- - ---------- ---------- ---------- ----------
1 A 500
2 B 6
3 C 6
4 D 8
5 E
Now If i want to remove every column from the result where value is null or 0. eg. XL column
it should give result like
IC I S M L
---------- - ---------- ---------- ---------- ----
1 A 500
2 B 6
3 C 6
4 D 8
5 E
thanks