How to use pivot for varchar column

  • Hi,

    I have a table like

    rowid CustLevel Code

    --------------------------------------------

    1 CustomerGroup MT

    2 Customerchannel GT

    3 Customer 6700001

    and I want result like

    Customer CustomerGroup Customerchannel

    --------------------------------------------------------

    MT GT 6700001

  • kuppurajm (3/30/2012)


    Hi,

    I have a table like

    rowid CustLevel Code

    --------------------------------------------

    1 CustomerGroup MT

    2 Customerchannel GT

    3 Customer 6700001

    and I want result like

    Customer CustomerGroup Customerchannel

    --------------------------------------------------------

    MT GT 6700001

    There's nothing in that data to positively associate the rows with each other when additional other rows are present. Do you have a "unique record" number or some other identifier that says those 3 rows belong to each other or are you guaranteeing that the rows will always be in the correct order by rowid AND always be in contiguous groups of 3? If neither is true, then this pretty much becomes a "crap shoot" with no guarantees that it'll continue to function correctly.

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