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

Tearadata SQL Help - Very much Urgent - response (7) by Qaisar Aftab Kiani

$
0
0
Hi, I don't  think there is an efficient way of getting what you want as all the tables joined together (OOFERATTRIBUTE, T_PROD_X_OTHER_HIER_PROD, T_PROD_DEF etc) are dependent on each other. See if this works for you for two products! SELECT (200000000000 + B.MAXID + ROW_NUMBER() OVER (ORDER BY SOR_PROD_CD)) AS LEAD_KY ,V.PRODUCT_1 AS SOR_PROD_CD ,COALESCE (LVL.PROD_CAT_LVL_1_NM, '-1') AS PROD_CAT_LVL_1_NM ,CURRENT_TIMESTAMP(0) AS AUD_INSRT_DT_TM ,USER AS AUD_INSRT_USR_ID FROM T_CNTCT_HIST C JOIN (SEL PRODUCT_1, OFFERCODE1 FROM OFFERATTRIBUTE) V ON C.VERS_ID = V.OFFERCODE1 JOIN BTNG.T_PROD_X_OTH_HIER_PROD PRD ON V.PRODUCT_1 = PRD.OTH_HIER_CHAR_PROD_CD AND PRD.EXPIR_DT = '9999-12-31' AND OTH_HIER_KY = 14 JOIN BTNG.T_PROD_DEF DEF ON DEF.PROD_KY = PRD.PROD_KY AND DEF.EXPIR_DT = '9999-12-31' AND PRD.EXPIR_DT = '9999-12-31' JOIN BTNG.T_PROD_CAT_LVL_1_DEF LVL ON DEF.PROD_CAT_LVL_1_KY = LVL.PROD_CAT_LVL_1_KY CROSS JOIN (SELECT COALESCE(MAX(LEAD_KY),0) MAXID FROM T_EMAIL_CCLR_PROD) B UNION ALL SELECT (200000000000 + B.MAXID + ROW_NUMBER() OVER (ORDER BY SOR_PROD_CD)) AS LEAD_KY ,V.PRODUCT_2 AS SOR_PROD_CD ,COALESCE (LVL.PROD_CAT_LVL_1_NM, '-1') AS PROD_CAT_LVL_1_NM ,CURRENT_TIMESTAMP(0) AS AUD_INSRT_DT_TM ,USER AS AUD_INSRT_USR_ID FROM T_CNTCT_HIST C JOIN (SEL PRODUCT_2, OFFERCODE2 FROM OFFERATTRIBUTE) V ON C.VERS_ID = V.OFFERCODE2 JOIN BTNG.T_PROD_X_OTH_HIER_PROD PRD ON V.PRODUCT_2 = PRD.OTH_HIER_CHAR_PROD_CD AND PRD.EXPIR_DT = '9999-12-31' AND OTH_HIER_KY = 14 JOIN BTNG.T_PROD_DEF DEF ON DEF.PROD_KY = PRD.PROD_KY AND DEF.EXPIR_DT = '9999-12-31' AND PRD.EXPIR_DT = '9999-12-31' JOIN BTNG.T_PROD_CAT_LVL_1_DEF LVL ON DEF.PROD_CAT_LVL_1_KY = LVL.PROD_CAT_LVL_1_KY CROSS JOIN (SELECT COALESCE(MAX(LEAD_KY),0) MAXID FROM T_EMAIL_CCLR_PROD) BThere could be some other way but without having some understanding of the data it is difficult to propose any effective solution.  

Viewing all articles
Browse latest Browse all 27759

Trending Articles



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