SQL Server2005 行转列
1select distinct '['+xmmc+'] as '+ xmmc+',' from gzljs_jhw where xn='2008-2009' and xq='2'
2
3select distinct '['+xmmc+'],' from gzljs_jhw where xn='2008-2009' and xq='2'
4
5'字段名称中不能有“(”等非法信息
2
3select distinct '['+xmmc+'],' from gzljs_jhw where xn='2008-2009' and xq='2'
4
5'字段名称中不能有“(”等非法信息
SELECT kkbm,jsbh,jsxm,
[【东方】毕业设计答辩] as 答辩,
[【东方】毕业设计评阅] as 评阅,
[【东方】毕业设计指导(理工科)] as 理科指导,
[【东方】毕业设计指导(其他)] as 其他指导,
[【东方】毕业设计指导(艺术类)] as 艺术指导,
[【东方】毕业实习] as 实习
FROM
(SELECT kkbm,jsbh,jsxm,xmmc,jshje
FROM gzljs_jhw where jsbh='20050047' ) p
PIVOT
(SUM (jshje)
FOR xmmc IN(
[【东方】毕业设计答辩],
[【东方】毕业设计评阅],
[【东方】毕业设计指导(理工科)],
[【东方】毕业设计指导(其他)],
[【东方】毕业设计指导(艺术类)],
[【东方】毕业实习])
)AS unpvt