had a question about using a count function or if i shuld even be using a count function for this...
Data I have to work with I would like my result set to look like this:
ID ID2 ID ID1Count ID2Count ID3Count ID4Count
A 1 A 2 2 2 3
A 1 B 1 0 3 1
A 2
A 3
A 2
A 4
A 4
A 4
A 3
B 3
B 4
B 1
B 3
B 3
I am stumped.... ANy help would be great... thanks!
nick
select ID,
sum(case when ID2 = 1 then 1 else 0 end) as ID1Count,
sum(case when ID2 = 2 then 1 else 0 end) as ID2Count,
sum(case when ID2 = 3 then 1 else 0 end) as ID3Count,
sum(case when ID2 = 4 then 1 else 0 end) as ID4Count,
from table1
group by ID|||Thanks for the direction! got it to work like a charm!
No comments:
Post a Comment