暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

GBASE南大通用分享:SQL优化

原创 淮海路小佩奇 2024-02-04
188

GBASE南大通用分享

笛卡尔积语法优化

ORACLE原始语法:

select xm.sfzh,xm.xm,ph.phone,ad.address

from ods.ods_connect_list_xm xm,ods.ods_connect_list_address ad,ods.ods_connect_list_phone ph

where xm.sfzh=ad.sfzh(+)

and xm.sfzh=ph.sfzh(+)

and ph.phone='2259261'

group by xm.sfzh,xm.xm,ph.phone,ad.address;


GBase优化语法:

select xm.sfzh,xm.xm,ph.phone,ad.address

from (select distinct sfzh,xm from ods.ods_connect_list_xm) xm

left join (select distinct sfzh,address from ods_connect_list_address) ad on xm.sfzh=ad.sfzh

left join (select distinct sfzh,phone from ods.ods_connect_list_phone where phone='2259261') ph on xm.sfzh=ph.sfzh

group by xm.sfzh,xm.xm,ph.phone,ad.address;


oracle语法: 


select

count(case when (NOT EXISTS(SELECT 1 FROM TJK.WAJ04 B WHERE B.WJ005=''AAC009'' AND IY02.AAC009 = B.WJ014) and IY02.AAC009 is not null) then ''1'' else null end) as "83"

from iy02 where ..............


GBase语法:


select

count(case when (t1.WJ014 is null and IY02.AAC009 is not null) then ''1'' else null end) as "83"

from iy02

left join

(select distinct WJ014 from WAJ04  )t1  on IY02.AAC009 = t1.WJ014

where ..............

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论