Row to Colums - please help a Newbie

  • Hi,

    Please help - I have tried to find a solution but with no success - I have the below data:

    Employee NoNameJob TitleTraining CodeTraining Code DescResultYear EnrolledTraining Start DateTraining End DateRank

    01763369LEKHANYA LHTEAM LEADER DEVELOPMENTWELLWPWELLNESS IN THE WORKPLACEPASS20102010/04/292010/04/291

    01763369LEKHANYA LHTEAM LEADER DEVELOPMENTTR7208DEVELOPMENT TEAM LEADERPASS20102010/12/022010/12/022

    Which I must change so that the colums show in one row:

    Employee NoNameJob TitleTraining CodeTraining Code DescResultYear EnrolledTraining Start DateTraining End DateRankTraining CodeTraining Code DescResultYear EnrolledTraining Start DateTraining End DateRank

    01763369LEKHANYA LHTEAM LEADER DEVELOPMENTWELLWPWELLNESS IN THE WORKPLACEPASS20102010/04/292010/04/291TR7208DEVELOPMENT TEAM LEADERPASS20102010/12/022010/12/022

    Your help would rally be much appreciated - thank you

  • How many rows per employee?

    Far away is close at hand in the images of elsewhere.
    Anon.

  • it will differ from employee but max will be 10 - Thank you

  • vilonel (4/8/2011)


    it will differ from employee but max will be 10 - Thank you

    Please check out the two links in my signature dealing with Cross-Tabs and Pivot tables - parts 1 and 2. Part 2 covers doing it dynamically, which if the # of columns will vary, this sounds like what you will be needing.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • thanks WayneS - will read the links - but will a pivot \ crosstab work for my scenario because I am not looking to sum, count etc values - I just want to have my dubplicate records in one row with the varouis training records next to each other per record (employee).

  • You can still use the pivot summing on an irrelevant column, and ignore it.

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • vilonel (4/8/2011)


    thanks WayneS - will read the links - but will a pivot \ crosstab work for my scenario because I am not looking to sum, count etc values - I just want to have my dubplicate records in one row with the varouis training records next to each other per record (employee).

    Just use MAX instead of SUM and it'll work just fine.

    --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.


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

  • Jeff Moden (5/15/2011)


    vilonel (4/8/2011)


    thanks WayneS - will read the links - but will a pivot \ crosstab work for my scenario because I am not looking to sum, count etc values - I just want to have my dubplicate records in one row with the varouis training records next to each other per record (employee).

    Just use MAX instead of SUM and it'll work just fine.

    or that... :hehe:

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg

Viewing 8 posts - 1 through 7 (of 7 total)

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