SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

peace
Constraint Violating Yak Guru

390 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

bandi
Flowing Fount of Yak Knowledge

India
2202 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

--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.03 seconds. Powered By: Snitz Forums 2000