All Forums Database
Ravindra Harve 2 posts Joined 01/06
09 Jan 2006
SQL Update

Hi,I am new to Teradata, and I need to do a SQL update. Based on the Syntax given in the Manual, I did write this SQL, but somehow this doesn't seem to work. Please let me know where I am going wrong?Thanks in Advance.UPDATE MSI_SUPPORT_TABLES.TBL_PERF_HIST_2_TESTfrom ( select a12.FSC_WK_END_DT FSC_WK_END_DT, a11.PRD_GRP_NBR PRD_GRP_NBR, a12.CMA_LCT_CD CMA_LCT_CD, sum(a11.TOT_SAL_AMT) SALES, sum(a11.TOT_CST_AMT) COST from ABC.PGP_SMY a11 join ABC.LCT_HST a12 on (a11.FSC_WK_END_DT = a12.FSC_WK_END_DT and a11.LCT_NBR = a12.LCT_NBR) group by a12.FSC_WK_END_DT, a11.PRD_GRP_NBR, a12.CMA_LCT_CD ) as A, MSI_SUPPORT_TABLES.TBL_PERF_HIST_2_TEST as bset TBL_PERF_HIST_2_TEST.CMA_LCT_CD = a.cma_lct_cd, TBL_PERF_HIST_2_TEST.TOT_SAL_AMT = a.SALES, TBL_PERF_HIST_2_TEST.TOT_CST_AMT = A.COSTwhere b.fsc_wk_end_dt = a.fsc_wk_end_dt and b.prd_grp_nbr = a.prd_grp_nbrRegards

TD_Arch 35 posts Joined 07/05
10 Jan 2006

The following is the working version of the SQL:UPDATE bfrom ( select a12.FSC_WK_END_DT FSC_WK_END_DT,a11.PRD_GRP_NBR PRD_GRP_NBR,a12.CMA_LCT_CD CMA_LCT_CD,sum(a11.TOT_SAL_AMT) SALES,sum(a11.TOT_CST_AMT) COSTfrom ABC.PGP_SMY a11join ABC.LCT_HST a12on (a11.FSC_WK_END_DT = a12.FSC_WK_END_DT and a11.LCT_NBR = a12.LCT_NBR)group by a12.FSC_WK_END_DT,a11.PRD_GRP_NBR,a12.CMA_LCT_CD) as A, MSI_SUPPORT_TABLES.TBL_PERF_HIST_2_TEST as bset CMA_LCT_CD = a.cma_lct_cd, TOT_SAL_AMT = a.SALES, TOT_CST_AMT = A.COSTwhere b.fsc_wk_end_dt = a.fsc_wk_end_dt and b.prd_grp_nbr = a.prd_grp_nbr

Ravindra Harve 2 posts Joined 01/06
10 Jan 2006

Thank You.RegardsRavi

You must sign in to leave a comment.