行转列

select * from 
(
select f.TABLE_FIELD_NAME_CN,RESOURCE_INFO_VALUE,FK_RESOURCE_INFO_INDEX_ID ID from [RESOURCE_INFOS] res
inner join  TABLE_FIELDS_MANAGE f on f.PK_TABLE_FIELD_ID=res.FK_TABLE_FIELD_ID
inner join  RESOURCE_INFO_INDEX i on i.PK_RESOURCE_INFO_INDEX_ID=res.FK_RESOURCE_INFO_INDEX_ID and
i.FK_EMERGENCY_CATEGORY_ID=1
) as t---要转的列表

pivot(
min([RESOURCE_INFO_VALUE])
for TABLE_FIELD_NAME_CN in (姓名,性别,所属公司,工作地点,技术专长)
) t2----转的条件

posted on 2014-10-14 18:48  中子持心  阅读(424)  评论(0编辑  收藏  举报

导航