SQL Update
Teradata Teradata Discussion Forums Teradata.com Discussion Forum
Visit Teradata.com
Home       Guidelines    Member List
Welcome Guest ( Login | Register )
        


This online forum is for user-to-user discussions of Teradata products, and is not an official customer support channel for Teradata. If you require direct assistance, please contact Teradata support.


SQL Update Expand / Collapse
Author
Message
Posted 1/9/2006 9:51:26 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 1/10/2006 10:27:00 PM
Posts: 2, Visits: 1
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_TEST
from ( 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 b
set 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.COST
where b.fsc_wk_end_dt = a.fsc_wk_end_dt
and b.prd_grp_nbr = a.prd_grp_nbr

Regards


Ravi
Post #3329
Posted 1/10/2006 4:32:54 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Forum Members
Last Login: 7/24/2008 8:31:03 AM
Posts: 109, Visits: 22
The following is the working version of the SQL:

UPDATE b
from ( 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 b
set CMA_LCT_CD = a.cma_lct_cd,
TOT_SAL_AMT = a.SALES,
TOT_CST_AMT = A.COST
where b.fsc_wk_end_dt = a.fsc_wk_end_dt
and b.prd_grp_nbr = a.prd_grp_nbr
Post #3333
Posted 1/10/2006 2:54:03 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 1/10/2006 10:27:00 PM
Posts: 2, Visits: 1
Thank You.

Regards
Ravi


Ravi
Post #3336
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.


All times are GMT -5:00, Time now is 3:30pm

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.078. 9 queries. Compression Disabled.