oracle join on 数据过滤问题
更新时间:2009年07月13日 21:36:17 作者:
因为在FOR .. IN () LOOP 游标中使用 所以不能采用下面的查询语句做游标
复制代码 代码如下:
select a.f_username
from
(
SELECT /*+parallel(gu,4)*/distinct gu.f_username
FROM t_base_succprouser gu
where gu.f_expectenddate > (select trunc(sysdate,'Y')FROM DUAL)
and gu.f_lotid=1
and gu.f_playid=4
and gu.f_paymoney>=1500
) A
left join
(
select
from t_base_vip_customes
and ((vu.f_passeddate is null ) or (vu.f_passeddate > trunc(sysdate,'Y') ))
and ((vu.f_lotid is null ) or (vu.f_lotid=1))
and ((vu.f_playid is null ) or (vu.f_playid=4))
and ((vu.f_condtionid is null ) or (vu.f_condtionid=3))
)B
on A.f_username=B.f_usernam
where b.f_username is null
采用下面的语句 只能查出部分用户
复制代码 代码如下:
SELECT /*+parallel(gu,4)*/distinct gu.f_username
FROM t_base_succprouser gu
left join t_base_vip_customes VU on gu.f_username=vu.f_username
gu.f_expectenddate > (select trunc(sysdate,'Y')FROM DUAL)
and gu.f_lotid=rec_viplotplay.f_lotid
and gu.f_playid=rec_viplotPlay.f_Playid
and gu.f_paymoney>=rec_viplotPlay.F_Conditon_ValuesA
and ((vu.f_passeddate is null ) or (vu.f_passeddate > trunc(sysdate,'Y') ))
and ((vu.f_lotid is null ) or (vu.f_lotid=rec_viplotplay.f_lotid))
and ((vu.f_playid is null ) or (vu.f_playid=rec_viplotPlay.f_Playid))
and ((vu.f_condtionid is null ) or (vu.f_condtionid=rec_viplotPlay.F_CondtionID))
and vu.f_username is null
执行计划:
复制代码 代码如下:
SELECT STATEMENT, GOAL = ALL_ROWS
HASH UNIQUE
NESTED LOOPS OUTER
PARTITION RANGE ALL
TABLE ACCESS FULL Object name=T_BASE_SUCCPROUSER
VIEW
FILTER
TABLE ACCESS FULL Object name=T_BASE_VIP_CUSTOMES
FAST DUAL
后来改成了下面就能全部查出来了
复制代码 代码如下:
SELECT /*+parallel(gu,4)*/distinct gu.f_username
FROM t_base_succprouser gu
left join t_base_vip_customes VU on gu.f_username=vu.f_username
and ((vu.f_passeddate is null ) or (vu.f_passeddate > trunc(sysdate,'Y') ))
and ((vu.f_lotid is null ) or (vu.f_lotid=rec_viplotplay.f_lotid))
and ((vu.f_playid is null ) or (vu.f_playid=rec_viplotPlay.f_Playid))
and ((vu.f_condtionid is null ) or (vu.f_condtionid=rec_viplotPlay.F_CondtionID))
where gu.f_expectenddate > (select trunc(sysdate,'Y')FROM DUAL)
and gu.f_lotid=rec_viplotplay.f_lotid
and gu.f_playid=rec_viplotPlay.f_Playid
and gu.f_paymoney>=rec_viplotPlay.F_Conditon_ValuesA
and vu.f_username is null
执行计划:
SELECT STATEMENT, GOAL = ALL_ROWS
HASH UNIQUE
FILTER
NESTED LOOPS OUTER
TABLE ACCESS BY GLOBAL INDEX ROWID Object name=T_BASE_SUCCPROUSER
INDEX RANGE SCAN Object name=IX_BASE_PROUSER_LOWEX
FAST DUAL
VIEW
TABLE ACCESS FULL Object name=T_BASE_VIP_CUSTOMES
oracle 不懂先把数据给过滤掉然后在来连接吗? 太笨了!而且这样把符合条件的数据也过滤掉了
相关文章
Oracle RAC环境下的阻塞(blocking blocked)介绍和实例演示
这篇文章主要介绍了Oracle RAC环境下的阻塞(blocking blocked)介绍和实例演示本文提供了2个查询脚本,并给出实例演示那些session为阻塞者,哪些为被阻塞者,需要的朋友可以参考下2014-09-09如何解决Oracle EBS R12 - 以Excel查看输出格式为“文本”的请求时乱码
这篇文章主要介绍了如何解决Oracle EBS R12 - 以Excel查看输出格式为“文本”的请求时乱码的相关资料,需要的朋友可以参考下2015-09-09解决ORA-01747:user.table.column,table.column或列说明无效
这篇文章主要介绍了解决ORA-01747:user.table.column,table.column或列说明无效的问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2023-07-07解决Oracle 查询时报错ORA-00923: FROM keyword not found where
这篇文章主要介绍了解决Oracle 查询时报错ORA-00923: FROM keyword not found where expected的问题,主要给大家介绍可能发生报错的几种情况,感兴趣的朋友跟随小编一起看看吧2023-03-03
最新评论