I am translating an Oracle SQL query to Teradata. The task is to update 2 columns in table A, one with a constant, the other with the max value for that column in table B, where the ID number matches the ID number in table A.
This is the Teradata code:
update tableA
from tableB
set
rsn_cd = max(tableB.rsn_cd)
where tableA.ID_num = tableB.ID_num,
src_cd = 'C
where tableA.ID_num in
(select
ID_num
from tableB
)
and src_cd = 'M'
and tableA.ID_num < 9000000000000
;
This produces a syntax error "3706 Syntax Error. Expected something between the word ID_num and ','" - referring to the where clause in the SET statement.
A further complication is that before I added the where clause, running the query produced the message '3872 Illegal use of an aggregate operation in an UPDATE statement' and if I read the text in the error manual correctly is a dead end. So even if the syntax problem is solved, this approach still may not work.
If anyone sees anything I am doing wrong or has a different approach, please let me know. Thanks.
This is the Teradata code:
update tableA
from tableB
set
rsn_cd = max(tableB.rsn_cd)
where tableA.ID_num = tableB.ID_num,
src_cd = 'C
where tableA.ID_num in
(select
ID_num
from tableB
)
and src_cd = 'M'
and tableA.ID_num < 9000000000000
;
This produces a syntax error "3706 Syntax Error. Expected something between the word ID_num and ','" - referring to the where clause in the SET statement.
A further complication is that before I added the where clause, running the query produced the message '3872 Illegal use of an aggregate operation in an UPDATE statement' and if I read the text in the error manual correctly is a dead end. So even if the syntax problem is solved, this approach still may not work.
If anyone sees anything I am doing wrong or has a different approach, please let me know. Thanks.