Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to remove blank column ?

only.ashish99Mar 8 2013 — edited Mar 9 2013
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 6 2013
Added on Mar 8 2013
8 comments
744 views