Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Help on Query Tunning - response (1) by rajeev saravanan

$
0
0
Hi, Since you are harcoding the date value we can avoid the join with the calender table depending on the volume of the data involved if its is not really high then probably we can try an approach involving cross join instead of multiple instances of left join to the same table on diff columns Some thing like this-   SELECT DP.Party_Id, cast('2012-09-21'  as Date) Clndr_Dt, Max(coalesce( (case when DL.Loctr_Id = DPL.RM_Rsdnl_Addr_Loctr_Id then DL.Soi_Num else null end),' '))AS RM_Cust_Res_Soi_Num , Max(coalesce( (case when DL.Loctr_Id = DPL.RM_Rsdnl_Addr_Loctr_Id then DL.Street_Nm else null end),' '))AS RM_Cust_Res_Street_Nm , Max(coalesce( (case when DL.Loctr_Id = DPL.RM_Rsdnl_Addr_Loctr_Id then DL.Moo_Num else null end),' '))AS RM_Cust_Res_Moo_Num , Max(coalesce( (case when DL.Loctr_Id = DPL.RM_Rsdnl_Addr_Loctr_Id then DL.Addr_Ln_1_Txt else null end),' '))AS RM_Cust_Res_Addr_Ln_1_Txt , Max(coalesce( (case when DL.Loctr_Id = DPL.RM_Rsdnl_Addr_Loctr_Id then DL.Addr_Ln_2_Txt else null end),' '))AS RM_Cust_Res_Addr_Ln_2_Txt , Max(coalesce( (case when DL.Loctr_Id = DPL.RM_Rsdnl_Addr_Loctr_Id then DL.Addr_Ln_3_Txt else null end),' '))AS RM_Cust_Res_Addr_Ln_3_Txt , Max(coalesce( (case when DL.Loctr_Id = DPL.RM_Rsdnl_Addr_Loctr_Id then DL.Tambol_Nm_TH else null end),' '))AS RM_Cust_Res_Tambol_Nm_TH , Max(coalesce( (case when DL.Loctr_Id = DPL.RM_Rsdnl_Addr_Loctr_Id then DL.Amphur_Nm_TH else null end),' '))AS RM_Cust_Res_Amphur_Nm_TH , Max(coalesce( (case when DL.Loctr_Id = DPL.RM_Rsdnl_Addr_Loctr_Id then DL.Province_Nm_TH else null end),' '))AS RM_Cust_Res_Province_Nm_TH , Max(coalesce( (case when DL.Loctr_Id = DPL.RM_Rsdnl_Addr_Loctr_Id then DL.Country_Nm_TH else null end),' '))AS RM_Cust_Res_Country_Nm_TH , Max(coalesce( (case when DL.Loctr_Id = DPL.RM_Rsdnl_Addr_Loctr_Id then DL.Postal_Cd_Id else null end),' '))AS RM_Cust_Res_Postal_Cd_Id , Max(coalesce( (case when DL.Loctr_Id = DPL.RM_Home_PhnNum_Loctr_Id then DL.Phn_Num else null end),' '))AS RM_Home_Phn_Num , Max(coalesce( (case when DL.Loctr_Id = DPL.RM_Ofcl_Email_Addr_Loctr_Id then DL.Elctrnc_Addr_Txt else null end),' '))AS Customer_electronic_Address from EDMSIT01_T3V_FND.DIM_PARTY DP LEFT JOIN EDMSIT01_T3V_FND.DIM_PARTY_LOCTR DPL ON DPL.Party_Id = DP.Party_Id and DPL.Eff_Start_Dt <= '2012-09-21' and DPL.Eff_End_Dt >= '2012-09-21' cross join  EDMSIT01_T3V_FND.DIM_LOCTR DL Where DP.Eff_Start_Dt <= '2012-09-21' and DP.Eff_End_Dt >= '2012-09-21' and DL.Eff_Start_Dt <= '2012-09-21' and DL.Eff_End_Dt >= '2012-09-21' ;   Please let me know if this was helpful   Thanks R.Rajeev    

Viewing all articles
Browse latest Browse all 27759

Trending Articles



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