Convert Rows to Columns Pivot

  • rnauman

    Newbie

    Points: 5

    [font="Courier New"]

    I have data in a table

    ManagerGoals

    EventID EEID CustValue

    107 12 JLK

    108 12 Manager

    109 12 50

    107 27 PEN

    108 27 Supervisor

    109 27 60

    107 31 DAV

    108 31 Manager

    109 31 50

    Need it like this

    EEID INIT TITLE GOALPERC

    12 JLK Manager 50

    27 PEN Supervisor 60

    31 DAV Manager 50

    Could be many more records and goal percent may change each month

    [/font]

  • Luis Cazares

    SSC Guru

    Points: 183637

    Take a look at these articles:

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns[/url]

    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs[/url]

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Jeff Moden

    SSC Guru

    Points: 997128

    Luis Cazares (10/19/2012)


    Take a look at these articles:

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns[/url]

    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs[/url]

    Heh... Man! You're fast!.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".
    "Dear Lord... I'm a DBA so please give me patience because, if you give me strength, I'm going to need bail money too!"

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Smash125

    Hall of Fame

    Points: 3527

    Good articles helped a lot thanks

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply