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 ! Create my free account now 🎁

Copied