Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 create new column to one row

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2013-03-14 : 05:07:08
ID IDStatus IDDate
1 Processing 2013-01-12
1 Pending 2013-01-15

Can i apply it in one row as below?

ID IDDateProcessing IDDatePending
1 2013-01-12 2013-01-15

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-03-14 : 06:07:50

select Id, [Processing] AS IDDateProcessing, [Pending] IDDatePending
from (SELECT * FROM TableName) p
Pivot( MAX(IDDate) FOR IDStatus IN ([Processing], [Pending]) )pvt

--
Chandu
Go to Top of Page
   

- Advertisement -