第一步:
设计表格MaxMin,结构如下:
里面填满了测试数据:
第二步:
写测试代码:
select PlayerSID, max(case RaterName when 'pw01' then MaxSign1+MinSign1+MaxSign2+MinSign2 else '' end) as 'pw01', max(case RaterName when 'pw02' then MaxSign1+MinSign1+MaxSign2+MinSign2 else '' end) as 'pw02', max(case RaterName when 'pw03' then MaxSign1+MinSign1+MaxSign2+MinSign2 else '' end) as 'pw03', max(case RaterName when 'pw04' then MaxSign1+MinSign1+MaxSign2+MinSign2 else '' end) as 'pw04', max(case RaterName when 'pw05' then MaxSign1+MinSign1+MaxSign2+MinSign2 else '' end) as 'pw05' FROM MaxMin group by PlayerSID
最新效果:
技术切记:
表格数据初始为Null时,会出现异常。初始化,为空时,初始化为空字符串 ''