1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Rows to Column Conversion

Discussion in 'SQL PL/SQL' started by itsbrat, Jul 23, 2010.

  1. itsbrat

    itsbrat Active Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    55
    Hey Guys I've a problem with my code efficiency... I need some help with converting my rows into columns..

    My table goes like this:
    Reg_num product Week_date N_count T_count
    123 a 02-jul 120 130
    123 b 25-jun 123 36546
    123 c 19-jun 323 567567
    123 d 12-jun 2345 67
    123 e 5-jun 345 567
    123 f 28-may 3465 567
    111 a 02-jul 321 213
    111 b 25-jun 345 345

    there is six weeks of data for every product and every reg_num...

    i want it in this format:

    Reg_num product wk1 wk2 wk3 wk4 wk5 wk6

    123 a 22 34 354 345 342 3244


    Can u guys help plz....
     
  2. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,351
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Re: HElp help.. rows to column conversion!!

    Show us your code so we can assist in tuning it for efficiency.
     
  3. itsbrat

    itsbrat Active Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    55
    Re: HElp help.. rows to column conversion!!

    Hey David.. Rite now i'm using arrays and loop for fetching each data and populating the other table which needs horizontal data.. What i'm lookin for is is there any way using decode function i can populate the other table??
     
  4. Sadik

    Sadik Community Moderator Forum Guru

    Messages:
    1,906
    Likes Received:
    252
    Trophy Points:
    1,455
    Re: HElp help.. rows to column conversion!!

    Please post the code you have.