adonetok
SSCrazy Eights
Points: 8395
More actions
October 4, 2011 at 3:10 pm
#104094
There is a table as below.
ID SEQ CODE
1001A
1002B
1011D
1012E
1013X
How to code to list as cross tab like below?
ID CODE1 CODE2 CODE3
100 A B
101 D E X
handkot
SSCertifiable
Points: 5251
October 5, 2011 at 6:13 am
#1390616
SELECT
ID
, MAX(CASE WHEN SEQ = 1 THEN CODE ELSE NULL END) CODE1
, MAX(CASE WHEN SEQ = 2 THEN CODE ELSE NULL END) CODE2
, MAX(CASE WHEN SEQ = 3 THEN CODE ELSE NULL END) CODE3
FROM
MYTABLE
GROUP BY
?
I Have Nine Lives You Have One OnlyTHINK!
October 5, 2011 at 7:30 am
#1390667
It works great.
Thanks
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply