Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Estimate and Actual are different and causing PJ. - response (2) by dnoeth

$
0
0

Are you taljking about the same problem as SPOLISETTI?
Teradata 12 and Subqueries
Avoid Correlated Scalar Subqueries and rewrite then to Outer Joins:

Select 
 m1.CLM_HDR_KEY,
 m1.CLM_NBR as CLM_NBR,
 m1.LOAD_DT,
 Cast(Cast(m1.CLM_FIN_PRCS_DT as date format 'yyyy/mm') as char(7)) as CLM_RPT_YR_MNTH_DS,
 Trim(m1.Grp_Nbr)||Trim(m1.Subgrp_nbr) as GRP_ID,
 m1.TYPE_OF_CLM_CD,
 m1.NETPAY_TOT_CLM_AMT as Tot_Netpay_Amt,
 m2.Tot_Alw_Amt 
 from
           OEAQ2.V_CLM_HDR_SUBSET_5_YRS m1
 left join 
  ( Select  m2.clm_hdr_key, m2.load_dt, 
            Sum(Coalesce(m2.CHG_AMT,0) - Coalesce(m2.CNTRC_PROV_SAV_AMT,0)) as Tot_Alw_Amt
            from OEAQ2.DW_CLM_LINE m2
            group by m2.clm_hdr_key, m2.load_dt
            ) as m2  --> (This is what being aggregated in step 13)
on  m2.CLM_HDR_KEY=m1.CLM_HDR_KEY
            AND m1.LOAD_DT=m2.LOAD_DT

where m1.Load_dt between '2011-01-01' and '2011-01-31'
          and m1.EXCL_CD = '';

 
Dieter


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>