Forum Replies Created

Viewing post 1 (of 1 total)

  • Reply To: Converting Columns to Rows based on specific column values

    another option is "unpivot"

    SELECT

    [Location]

    ,Customer

    ,Product

    ,SalesOrderNumber

    ,Price

    ,CreatedDate

    ,ChargeName

    ,ChargeAmount

    FROM

    (

    SELECT

    [Location]

    ,Customer

    ,Product

    ,SalesOrderNumber

    ,Price

    ,CreatedDate

    ,Charge1

    ,Charge2

    ,Charge3

    ,Charge4

    ,Charge5

    FROM

    #Results

    ) x

    UNPIVOT

    (

    ChargeAmount FOR ChargeName IN

    (

    Charge1

    ,Charge2

    ,Charge3

    ,Charge4

    ,Charge5

    )

    )AS unpvt;

Viewing post 1 (of 1 total)