Query Problem

Training
Enthusiast

Query Problem

update tabl_name
set
id = ( sel id as SCI
From cycle_Calendar
Where cde ='AC'
And id = (sel Min(id)
From cycle_calendar
Where cde = 'AC'
And ST_cde = -20))

When I execute this query, I get Syntax error. Expected something between '(' and 'sel'
1 REPLY
Enthusiast

Re: Query Problem

That's an invalid syntax for Teradata. You cannot code a subselect within the SET clause of the UPDATE statement. Instead, you need to create a derived table and then use the column from the derived table in your set. Something like:

update tn
from tabl_name
,( sel id as SCI
From cycle_Calendar
Where cde ='AC'
And id = (sel Min(id)
From cycle_calendar
Where cde = 'AC'
And ST_cde = -20)) dt
set id = dt.SCI

Hope that helps.