SELECTING ROW VALUES AS COLUMN BASED ON A KEY

  • I had a scenorio where i need to retrieve the row values in column values.

    Let me Explain with the below Example:

    Table :

    Transaction_ID | PID | Field_key

    B001 | 4 | A

    B001 | 4 | B

    B001 | 4 | C

    C001 | 2 | 100

    C001 | 2 | 200

    Please Note that: This table doesn't have any Primary Key or Unique Key

    OUTPUT Should be

    Transaction_ID | PID | Field_Key1 |Field_Key2 | Field_Key3

    B001 | 4 | A | B | C

    C001 | 2 | 100 | 200 | NULL

    Thanks,

    shashidhar

  • Look in books online for the PIVOT clause for SELECT statements.

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

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