select max(case 类别 when '电子类' then 电压 end) as 电子类电压
,max(case 类别 when '电子类' then 长度 end) as 电子类长度
,max(case 类别 when '电子类' then 颜色 end) as 电子类颜色
,max(case 类别 when '电子类' then 容量 end) as 电子类容量
,max(case 类别 when '建材类' then 电压 end) as 建材类电压
,max(case 类别 when '建材类' then 长度 end) as 建材类长度
,max(case 类别 when '建材类' then 颜色 end) as 建材类颜色
,max(case 类别 when '建材类' then 容量 end) as 建材类容量
,max(case 类别 when '日用类' then 电压 end) as 日用类电压
,max(case 类别 when '日用类' then 长度 end) as 日用类长度
,max(case 类别 when '日用类' then 颜色 end) as 日用类颜色
,max(case 类别 when '日用类' then 容量 end) as 日用类容量
from(
select a.类别,b.电压,b.长度,b.颜色,b.容量 from Q_Category a,Item b
where a.PKID=b.类别PKID
) aa
,max(case 类别 when '电子类' then 长度 end) as 电子类长度
,max(case 类别 when '电子类' then 颜色 end) as 电子类颜色
,max(case 类别 when '电子类' then 容量 end) as 电子类容量
,max(case 类别 when '建材类' then 电压 end) as 建材类电压
,max(case 类别 when '建材类' then 长度 end) as 建材类长度
,max(case 类别 when '建材类' then 颜色 end) as 建材类颜色
,max(case 类别 when '建材类' then 容量 end) as 建材类容量
,max(case 类别 when '日用类' then 电压 end) as 日用类电压
,max(case 类别 when '日用类' then 长度 end) as 日用类长度
,max(case 类别 when '日用类' then 颜色 end) as 日用类颜色
,max(case 类别 when '日用类' then 容量 end) as 日用类容量
from(
select a.类别,b.电压,b.长度,b.颜色,b.容量 from Q_Category a,Item b
where a.PKID=b.类别PKID
) aa
我是希望把竖表转成横表
而不是取各列的最大 值
是一对一的关系