|
--such?
create table T (id int, type int)
insert T select 1, 1
union all select 1, 2
union all select 1, 3
union all select 2, 3
select id,
'A' = max (case type when 1 then 1 end),
'B' = max (case type when 2 then 2 end),
'C' = max (case type when 3 then 3 end)
from T
group by id
--result
id A B C
----------- ----------- ----------- -----------
1 1 2 3
2 NULL NULL 3
(2 row (s) affected) |
|