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

Design change / Perf Optimization Suggestion required - response (1) by Fred

$
0
0

For TD13.10 or later, you could use a scalar subquery:
 
SEL count(1) FROM 

  SELECT RTL_ID RetailID,
       CATG_ID CATGID,
       Shipment_Dt ,
       MAX(Catg_Store_Selling_13Wk_Cnt) AS CatgStoreCount
               FROM Mim_tbl.retail_shipment_t
GROUP BY 1,2,3
  )  CATG_STORE_AGG 
WHERE CATG_STORE_AGG.Shipment_DT = (SELECT TMP.YAGO_DT
FROM MIM_TBL.CURR_YAGO_CAL TMP
WHERE TMP.CAL_DT = date'2013-05-11')
 
But why not just put the join inside the GROUP BY, which is what you are trying to achieve anyway:
 
SEL count(1) FROM 
(  SELECT RTL_ID RetailID,
       CATG_ID CATGID,
       Shipment_Dt ,
       MAX(Catg_Store_Selling_13Wk_Cnt) AS CatgStoreCount
               FROM Mim_tbl.retail_shipment_t
INNER JOIN
MIM_TBL.CURR_YAGO_CAL TMP
ON 
CATG_STORE_AGG.SHipment_DT = TMP.CAL_DT
WHERE TMP.CAL_DT = date'2013-05-11'
GROUP BY 1,2,3
  )  CATG_STORE_AGG 
;
 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



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