当前位置: 代码迷 >> Oracle管理 >> sql语句优化,该怎么处理
  详细解决方案

sql语句优化,该怎么处理

热度:102   发布时间:2016-04-24 05:52:48.0
sql语句优化
select dn,
  node,
  (select sum(a.clear_during)
  from al_history a
  where a.org_no = 65396
  and a.dn = t.dn
  and a.node = t.node) as Mains,
  (select sum(b.clear_during)
  from al_history b
  where b.org_no = 65397
  and b.dn = t.dn
  and b.node = t.node) as DG,
  (select sum(c.clear_during)
  from al_history c
  where c.org_no = 65398
  and c.dn = t.dn
  and c.node = t.node) as Battery
  from al_history t
  where (org_no = 65396)
  or (org_no = 65397)
  or (org_no = 65398)
  group by t.dn, t.node

------解决方案--------------------
同一张表啊
不用这么复杂
用decode+sum就可以实现
------解决方案--------------------
探讨
同一张表啊
不用这么复杂
用decode+sum就可以实现
  相关解决方案