将Oracle查询转换为teradata查询

时间:2016-01-06 17:36:12

标签: oracle teradata

如何将以下查询转换为等效的teradate查询。我试过,但结果差异很大。

select il.domainN as listname, il.SourceID, ns.sourcename, cbo.customerid, cu.username, hv.domainN as HTname
,  nvl((select 1 
        from mydb.customerPP cpp 
        where cbo.customerid = cpp.customerid 
          and NOT EXISTS (select 1 from mydb.customerPI cpt where cpp.customerid = cpt.customerid)
          and trunc(cpp.startdate) <= sysdate
        group by cpp.customerid),0) as BBID
from mydb.customerBO cbo
  join mydb.customers cu on cbo.customerid = cu.customerid
  join mydb.inv il on cbo.domainN = il.domainN
  join mydb.Sources ns on il.SourceID = ns.SourceID
  left join mydb2.HT hv on (il.domainN = hv.domainN
                                  and hv.sDate+1 >= il.dDate
                                  and il.dDate+1 >= hv.sDate)
where cbo.customerBOID = 1 
  and cu.statusid = 1
  and il.sourceTID = 2
  and il.joinbydate >= cbo.cDate 
  and trunc(il.dDate) = trunc(sysdate)

感谢。

1 个答案:

答案 0 :(得分:0)

使用coalesce而不是nvl并比较explain语句,以查看是否已将外部联接转换为Teradata上nvl的内部联接。