Convert Column value to Row

  • Hi,

    I want to convert Single Column values to Row.

    Table Original Content:

    Code Amount Expenditure

    10027 5000.00LOCAL CONVEYANCE

    10027 320.00LOCAL CONVEYANCE

    10116 1589.00TRAVEL EXPENSES

    10095 350.00LOCAL CONVEYANCE

    10095 1215.00TRAVEL EXPENSES

    Expected Output :

    CodeLCTE

    100275000.00NULL

    10027320.00NULL

    10116NULL1589.00

    10095350.001215.00

    Thanks in Advance

  • See the following article for how to easily do Crosstabs and Pivots:

    http://www.sqlservercentral.com/articles/T-SQL/63681/

    See the first link in my signature below if you'd like a coded answer.

    --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 2 (of 2 total)

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