I have table like this
ID TimeStamp Statement Action
8082837636688904709 2012-07-23 16:03:25.000 UPDATE Skill name="French" SET state="1" 1
8082837636688904709 2012-07-23 16:03:25.000 UPDATE Skill name="French" SET state="2" 2
and I want to transpose it like:
ID TimeStamp UndoStatement RedoStatement
8082837636688904709 2012-07-23 16:03:25.000 UPDATE Skill name="French" SET state="1" UPDATE Skill name="French" SET state="2"
This is my query:
SELECT ID, Timestamp, [UndoStatement], [RedoStatement]
FROM (
SELECT ID, TimeStamp, Statement, Action From Transactions) a
PIVOT
(
MAX(Statement) FOR Statement IN ([UndoStatement], [RedoStatement])
) as pvt
and this is what I get
ID UndoStatement RedoStatement
8082837636688904709 NULL NULL
8082837636688904709 NULL NULL
Can anyone tell what I'm doing?