Monday, 17 September 2012

Pivote table ( change rows as columns)




select decode( r, 1, to_char(sal), 2, sno)
from salary, (select rownum r from all_objects where rownum <= 2 )
where sno = 1

select stno,
       max(decode(rn,1,course_code)) s1,
       ...
       max(decode(rn,N,course_code)) sN
  from ( select stno, course_code,
                row_number() over (partition by stno order by course_code )
           from t )
 group by stno

No comments:

Post a Comment