How to do it...

  1. Check for duplicate values in the source table using the following:
/*Check for duplicate values in source table*/SELECT cust_id,count(*) 
from Hr_payhike
group by 1 order by 2 desc
  1. The output will be generated with CUST_ID =1 and has two values which are causing errors. The reason for this is that while updating the TARGET table, the optimizer won't be able to understand from which row it should update the TARGET row. Who's salary will be updated Will or Bekky?
  2. To resolve the error, execute the following update query:
/* Update part of MLOAD */UPDATE ACC
FROM ACCOUNTS ACC , 
( SELECT CUST_ID,
CUST_NAME,
SAL_HIKE 
FROM 
Hr_payhike
QUALIFY ROW_NUMBER() OVER (PARTITION BY CUST_ID ORDER BY CUST_NAME,SAL_HIKE DESC)=1) SUPD

Get Teradata Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.