读书人

有时间的帮忙看上

发布时间: 2012-09-24 13:49:41 作者: rapoo

有时间的大虾帮忙看下

HTML code
TYPE    VALUE节点名称    模块一NAME    小明AGE    25

数据库的表是上面的格式。能不能将表中的数据直接查询为下面的格式。谢谢啊
节点名称NAMEAGE
模块一小明25

[解决办法]
SQL code
select [节点名称]= case when type='节点名称' then value end ,[NAME]= case when type='NAME' then value end  ,[AGE]= case when type='AGE' then value end from 表
[解决办法]
SQL code
select [节点名称]= case when type='节点名称' then value end ,[NAME]= case when type='NAME' then value end  ,[AGE]= case when type='AGE' then value end from 表case  when就好了
[解决办法]
select max(case type when '节点名称' then value else 0 end) as 节点名称,
max(case type when 'NAME' then value else 0 end) as NAME,
max(case type when 'AGE' then value else 0 end) as AGE,
from XXX group by xxx

读书人网 >SQL Server

热点推荐