Results 1 to 4 of 4

Thread: Pivot columns

  1. #1
    Junior Member
    Join Date
    Oct 2007
    Answers
    12

    Question Pivot columns

    Is there any command to display ROWS as COLUMNS and vice-versa??


  2. #2
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Pivot columns

    Try to use decode for the purpose.


  3. #3
    Junior Member
    Join Date
    Oct 2007
    Answers
    4

    Re: Pivot columns

    Dear,

    As this is requrie for the reports, it can be done to preapre the matrix report


  4. #4
    Contributing Member
    Join Date
    Apr 2006
    Answers
    46

    Re: Pivot columns

    according to the moderator u can use decode for it

    here is a sample------

    with t as
    (
    select 'a' as col from dual
    union
    select 'a' from dual
    union
    select 'b' from dual
    )
    select *from t;

    a
    a
    b


    now yr needed code here --->

    select
    max(decode(rn, 1, col)) col1,
    max(decode(rn, 2, col)) col2,
    max(decode(rn, 3, col)) col3
    from (
    select col, row_number() over (partition by col order by col) rn
    from t
    order by col)
    group by col

    o/p is----------->

    a a
    b

    hpoe u can get it.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact