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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 create new column to one row
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

420 Posts

Posted - 03/14/2013 :  05:07:08  Show Profile  Reply with Quote
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

Flowing Fount of Yak Knowledge

2242 Posts

Posted - 03/14/2013 :  06:07:50  Show Profile  Reply with Quote

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

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000