日期:2014-05-17 浏览次数:20521 次
with tb(Id,编号,型号,类型,用户,商家)as(
select 1,1001,'黑金刚','内存','小黄','畅能科技' union
select 2,1002,'七彩虹','主板','小黄','畅能科技' union
select 3,1003,'速龙','cpu','小黄','畅能科技' union
select 4,1004,'西数160G','硬盘','小黄','畅能科技' union
select 5,1005,'威刚','内存','小李','昌泰科技' union
select 6,1006,'三星','硬盘','小李','昌泰科技' union
select 7,1007,'双敏','显卡','小李','昌泰科技' union
select 8,1008,'英特尔','cpu','小李','昌泰科技' union
select 9,1009,'双敏','主板','小李','昌泰科技' union
select 10,1010,'金士顿','内存',NULL,'昌泰科技')
select 用户,
MAX(case when 类型='CPU' then convert(varchar,编号)+型号 else null end) CPU,
MAX(case when 类型='主板' then convert(varchar,编号)+型号 else null end) 主板,
MAX(case when 类型='硬盘' then convert(varchar,编号)+型号 else null end) 硬盘,
MAX(case when 类型='内存' then convert(varchar,编号)+型号 else null end) 内存,