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

Tearadata SQL Help - Very much Urgent - response (8) by Mathuram

$
0
0
Try this Query, i think it will work... WITH TEMP (LEAD_KY,PROD_CAT_LVL_1_NM,  AUD_INSRT_DT_TM, AUD_INSRT_USR_ID,PRODUCT_1, PRODUCT_2, PRODUCT_3, PRODUCT_4, PRODUCT_5) as (SELECT   (200000000000 + B.MAXID + ROW_NUMBER() OVER (ORDER BY SOR_PROD_CD)) AS LEAD_KY ,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 ,V.PRODUCT_1 AS SOR_PROD_CD, V.PRODUCT_2, V.PRODUCT_3, V.PRODUCT_4, V.PRODUCT_5 FROM  T_CNTCT_HIST C JOIN (SEL PRODUCT_1, PRODUCT_2, PRODUCT_3, PRODUCT_4, PRODUCT_5,PRODUCT_6, PRODUCT_7, PRODUCT_8, PRODUCT_9, PRODUCT_10, 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) SEL LEAD_KY,PROD_CAT_LVL_1_NM,  AUD_INSRT_DT_TM, AUD_INSRT_USR_ID,PRODUCT_1 FROM TEMP UNION ALL SEL LEAD_KY,PROD_CAT_LVL_1_NM,  AUD_INSRT_DT_TM, AUD_INSRT_USR_ID,PRODUCT_2 FROM TEMP UNION ALL SEL LEAD_KY,PROD_CAT_LVL_1_NM,  AUD_INSRT_DT_TM, AUD_INSRT_USR_ID,PRODUCT_3 FROM TEMP UNION ALL SEL LEAD_KY,PROD_CAT_LVL_1_NM,  AUD_INSRT_DT_TM, AUD_INSRT_USR_ID,PRODUCT_4 FROM TEMP UNION ALL SEL LEAD_KY,PROD_CAT_LVL_1_NM,  AUD_INSRT_DT_TM, AUD_INSRT_USR_ID,PRODUCT_5 FROM TEMP

Viewing all articles
Browse latest Browse all 27759

Trending Articles



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