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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 row to column

Author  Topic 

jung1975
Aged Yak Warrior

503 Posts

Posted - 2008-01-03 : 15:00:00
I have a table looks like below


ID assessmnet_dt employment_cd reason_cd
1 01/01/07 1 5
1 03/11/07 3 9
2 11/01/07 11 1
2 12/05/07 3 7
3 07/22/06 4 1


And I am trying to transfrer row to column ( T1 and T2) based on the ID and assessment_dt.. If there is only one record with one assessment_Dt , put the same information for t1 and T2

ID T1_assessmnet_dt T1_employment_cd T1_reason_cd T2_assessmnet_dt T2_employment_cd T2_reason_cd
1 01/01/07 1 5 03/11/07 3 9
2 11/01/07 11 1 12/05/07 3 7
3 07/22/06 4 1 07/22/06 4 1

is there any new SQL syntax in 2005 that i can use to accomplish this?


X002548
Not Just a Number

15586 Posts

Posted - 2008-01-03 : 15:05:34
What happens if you have 100 ID 1's?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -