28 July 2018        Add to Favorites   Report

Teradata UPDATE FROM syntax using row Number

Solution:

Here's the teradata update from syntax.  You have to specify the row_number in the inner derived table

UPDATE TargetTable
FROM
 (
   SELECT text_id,
      (SELECT MAX(ID) FROM serviceClusters) +
      ROW_NUMBER() OVER (ORDER BY Text_ID) AS newID 
   FROM TargetTable
 ) AS src
SET ID = newID
WHERE TargetTable.Text_ID = src.Text_ID

Read great educational content like this and a lot more !

Members get free exclusive access to content, new courses, and discounts. Signup for a free account to write a post / comment / upvote posts. Creating an account takes less than 5 seconds and you can start earning badges & points too

Copied