combining rows with common index values

  • This is probably very simple, but I am still learning and haven't been able to figure this out.

    I have a table that lists employee skills:

    employee1 skill1

    employee1 skill2

    employee1 skill3

    employee2 skill2

    employee3 skill1

    employee3 skill5

    I need to create a view that shows all the skills for each employee on the same row, either concatenated:

    employee1 skill1, skill2, skill3

    employee2 skill2

    employee3 skill1, skill5

    or in seperate columns

    employee1 skill1 skill2 skill3

    employee2 skill2 null null

    employee3 skill1 skill5 null

    One of the challenges is that an employee may have anywhere from 0 to ten skills.

    Anyone have an easy solution?

  • Dupe post... please continue at the following so all the answers stay in the same place...

    http://www.sqlservercentral.com/Forums/Topic518657-149-1.aspx

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

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

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