Example: UPDATE with a Scalar Noncorrelated Subquery in the SET Clause - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

You can specify a scalar subquery in the same way that you specify a column or constant in the SET clause of an UPDATE request.

The following example specifies a scalar subquery in its SET clause:

     UPDATE sales_sum_table AS sst
     SET  total_sales = (SELECT SUM(amount)
                         FROM sales_table AS s
                         WHERE s.day_of_sale BETWEEN sst.period_start 
                                             AND     sst.period_end);