Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

help required for a update scenario - response (4) by Qaisar Aftab Kiani

$
0
0

Replace CUSTOMER_TEST with your table name and I hope the below query will work for you

UPDATE TBLA
FROM CUSTOMER_TEST TBLA, CUSTOMER_TEST TBLB, (SELECT CUSTOMER_ID FROM CUSTOMER_TEST WHERE CUSTOMER_ID = 'C1' QUALIFY RANK() OVER(ORDER BY DATE_)=1) TBLC
SET CAL_QTY = CASE WHEN TBLC.CUSTOMER_ID IS NOT NULL THEN TBLB.QTY ELSE TBLB.CAL_QTY END
WHERE TBLA.CUSTOMER_ID = TBLB.CUSTOMER_ID
AND TBLA.PRODUCT = TBLB.PRODUCT
AND TBLA.DATE_ = TBLB.DATE_

 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>