I need to update table records in teradata using SQL codes. I need to conversation sql codes to teradata syntax. Has someone got any iddia how to convert following sql codes to teradata sytax.
it would be easier if you would describe what the update should do.
So I could only give a guess from the code...
select a.Column_1,a.Column_2 ,
COUNT(*) as Column_3,
(SUM(Column_6) +sum(Column_7)) as Column_4
from Table_B a inner join Table_C b
and a.Column_1= 20120601 and a.Column_2=5
where --> table_a and derived table M join condition;
So you specify your dervied table in the from clause.
and define in the where clause the join condition between the table_a and the derived table M.
Thanks for your advice. I think the problem is that joining data (select statements) and update clause.
I will try to run script as you write. If i get error, i will share more details of error. Next time, i will give more details; table names, column names,... etc. So, it will be better way to help me.
Check the Update syntax diagram in the manuals
What I can see is the the set needs a , instead of an and
(select main_zone_id, zone_no, sales_count, sales_sum
select 1420 as main_zone_id, 17 as zone_no, count(*) as sales_count,
(sum(usd_amount) + sum(euro_amount) ) as sales_sum
from new_cust_table a
inner join new_dealer_table b
on a.prodid = b.prodid
where proddescid = 5
on a.tran_area_id = b.tran_area_id
and a.main_zone_id = b.main_zone_id
where a.main_zone_id = 1265
and a.zone_no = 48
and zone_status_flag = 'F'
set k.sales_count = m.sales_count
,k.sales_sum = m.sales_sum
You need to write the derived table M in a way that you can execute it on itself (copy / paste into SQLA) and gives a result set which you can join to the target table.