Pivot or Crosstab question

  • I have a table like this:

    Item       Comp        CAS


    A            Green       5105-0

    A            Blue          3133              

    A            Yellow       2123-5

    A            L. Yelow    2244

    A            L. Green     2233

    B            blue             2334-1

    B            Yellow          123-1

    B            White           2233-3

    B            L.Green       2291

    B            L. Blue      8883-0-1

    How do I turn into this?

    Item  Comp1   CAS1   Comp2  CAS2   Comp3   CAS3   Comp4    CAS4    Comp5   CAS5


    A      Green     5105-0  Blue     3133    Yellow   2123-5  L.Yellow   2244   L.Green  2233

    B      Blue        2334-1 Yellow   123-1   White   2233-3  L.Green   2291    L.Blue   8883-0-1

    The maximum number of comp is five for each Item and the comp has to stay in the same sequence.

    Thanks.

     

  • Looks like the solution for this problem and a lot more  is in http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=242919

    Thanks,

    Chandra

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

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