日期:2014-05-17  浏览次数:20370 次

有时间的大虾帮忙看下
HTML code

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


数据库的表是上面的格式。能不能将表中的数据直接查询为下面的格式。谢谢啊
节点名称 NAME AGE
模块一 小明 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