select t3.*, nvl(t5.sum_kcsl, 0) sum_kcsl, nvl(t5.sum_clsl, 0) sum_clsl
from (select t2.fydm,
t2.mc,
t2.gg,
t2.kfbh,
t2.pch,
t2.sfkccl,
t2.dw,
t2.jx,
t2.dj,
sum(t2.sl) as zsl,
sum(t2.je) as zje
from zl_zydj t, fy_fymx t2
where t2.jzxh = t.jzxh
and t2.zhbh = t.zhbh
and t2.zxbz = '0'
and (t2.fylb = '0' or t2.wzlb = '1')
and t2.kfbh = '103116'
and t2.zhbh = '3305230028'
and t2.fyzt = '0'
and t2.jzlb = '1'
and t.zyzt <> '4'
group by t2.fydm,
t2.mc,
t2.gg,
t2.kfbh,
t2.pch,
t2.sfkccl,
t2.dw,
t2.jx,
t2.dj
) t3
left join (select t4.wzbh,
t4.kfbh,
t4.pch,
sum(t4.kcsl) as sum_kcsl,
sum(t4.clsl) as sum_clsl
from kc_pckctz t4
where 1 = 1
and t4.kfbh = '103116'
and t4.zxbz = '0'
and t4.sfty = '0'
and t4.zhbh = '3305230028'
and t4.yxqz >= '20170214'
and (t4.kcsl <> 0.0 or t4.clsl <> 0.0)
group by t4.wzbh, t4.kfbh, t4.pch) t5
on t3.pch = t5.pch
and t3.fydm = t5.wzbh
and t3.kfbh = t5.kfbh
and ((decode(t3.pch, null, 1, 0)) = 1 or
(t5.sum_kcsl <> 0 or t5.sum_clsl <> 0))下面是执行计划:
from (select t2.fydm,
t2.mc,
t2.gg,
t2.kfbh,
t2.pch,
t2.sfkccl,
t2.dw,
t2.jx,
t2.dj,
sum(t2.sl) as zsl,
sum(t2.je) as zje
from zl_zydj t, fy_fymx t2
where t2.jzxh = t.jzxh
and t2.zhbh = t.zhbh
and t2.zxbz = '0'
and (t2.fylb = '0' or t2.wzlb = '1')
and t2.kfbh = '103116'
and t2.zhbh = '3305230028'
and t2.fyzt = '0'
and t2.jzlb = '1'
and t.zyzt <> '4'
group by t2.fydm,
t2.mc,
t2.gg,
t2.kfbh,
t2.pch,
t2.sfkccl,
t2.dw,
t2.jx,
t2.dj
) t3
left join (select t4.wzbh,
t4.kfbh,
t4.pch,
sum(t4.kcsl) as sum_kcsl,
sum(t4.clsl) as sum_clsl
from kc_pckctz t4
where 1 = 1
and t4.kfbh = '103116'
and t4.zxbz = '0'
and t4.sfty = '0'
and t4.zhbh = '3305230028'
and t4.yxqz >= '20170214'
and (t4.kcsl <> 0.0 or t4.clsl <> 0.0)
group by t4.wzbh, t4.kfbh, t4.pch) t5
on t3.pch = t5.pch
and t3.fydm = t5.wzbh
and t3.kfbh = t5.kfbh
and ((decode(t3.pch, null, 1, 0)) = 1 or
(t5.sum_kcsl <> 0 or t5.sum_clsl <> 0))下面是执行计划:
解决方案 »
- 一个存储过程调用报错。
- 求教各位达人:win7家庭版能装Oracle11g吗?
- 数据库处于归档模式与非归档模式是什么意思
- 请教表连接查询
- 如何用透明网关连接db2
- 出现错误提示:ORA-04031: 无法分配 8192 字节的共享内存 ("large pool","unknown object","cursor work he","get new buffer")
- 读数据的问题??
- oracle客户端怎么连接服务器??没分的菜鸟吐血等待ing...
- 一个序列可以被多个触发器使用吗?会不会受影响?
- 一个安装的问题oracle8.1.7??
- SQL SERVER 存储过程 如何转换为ORACLE 存储过程 特别是存储过程如何实现SELECT
- oracle11g的dmp文件怎么导入到oracle10g中,一导入就报错。
2、根据业务需要,适当的引用 sum over(partition by ),会比group by那么多列快

and t.zhbh = '3305230028'