dcsimg
Results 1 to 2 of 2

Thread: Pivot the columns data

  1. #1
    Join Date
    Oct 2011
    Posts
    1

    Pivot the columns data

    I have oracle table which has like below example in col7 column there will be values seperated , in one column it is kind of horizontal pivoting but the data is in 1 column seprated ,

    In near future this col7 and col8 may have some more values


    col7 * col8 that many records it should create


    col1| clo2| col3| col4| clo5|col7 | col8
    ahy |ahx |axs |aht |azs |LO1,LO2,LO3,LO4 |LH1,LH2,LH3
    zas |bsz |dgf |asd |ans |LO5,LO6 |LH7

    I need the ouptput like
    col1 clo2 col3 col4 clo5 col7 col8
    ahy ahx axs aht azs LO1 LH1
    ahy ahx axs aht azs LO1 LH2
    ahy ahx axs aht azs LO1 LH3
    ahy ahx axs aht azs LO2 LH1
    ahy ahx axs aht azs LO2 LH2
    ahy ahx axs aht azs LO2 LH3
    ahy ahx axs aht azs LO3 LH1
    ahy ahx axs aht azs LO3 LH2
    ahy ahx axs aht azs LO3 LH3
    ahy ahx axs aht azs LO4 LH1
    ahy ahx axs aht azs LO4 LH2
    ahy ahx axs aht azs LO4 LH3
    zas bsz dgf asd ans LO5 LH7
    zas bsz dgf asd ans LO6 LH7
    I know this can be done in sql by using pivot and decode but any one could give some smaple script it would be really helpfull for me.Thank you very much
    Last edited by marpadga18; 10-26-2011 at 12:38 PM.

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    If you use sql server, can find syntax and sample code in books online.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •