当前位置: 代码迷 >> Oracle开发 >> oracle多条记录合并一条有关问题
  详细解决方案

oracle多条记录合并一条有关问题

热度:80   发布时间:2016-04-24 06:42:20.0
oracle多条记录合并一条问题


我想显示成下面这样的,只有一条数据


------解决方案--------------------
写个土方法
with tt as(
select 1 id,'c1' nn from dual
union
select 2,'c2' from dual
union
select 3,'c3' from dual
)
select sum(c1) c1,sum(c2) c2,sum(c3) c3
from
(select case nn when 'c1' then id else 0 end c1,
       case nn when 'c2' then id else 0 end c2,
       case nn when 'c3' then id else 0 end c3  
       from tt) 
------解决方案--------------------
select pfkid,max(decode(wrlx,'烟尘',wrvalue)) '烟尘',max(decode(wrlx,'氮氧化物,wrvalue)) 氮氧化物,max(decode(wrlx,'烟气湿度',wrvalue))  烟气湿度 from 表 group by pfkid
  相关解决方案