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

Update statement with left outer join in from clause. - response (1) by dnoeth

$
0
0

Hi Harpreet,
is this an actually update statement? (SQL Server?)
There's no condition to join to CDD_Today.
 
You might rewrite it:

  • use a Correlated Subquery 

UPDATE Staging.CDD_Today
SET ABC_Risk = 
 ( SELECT b.riskfactor
   FROM Staging.CDD_TodayCDD_CountryRisk a
   LEFT JOIN dbo.CDD_ABC_Uplift b ON b.REVIEW_ID = a.REVIEW_ID
   AND b.COUNTRY_NAME = a.ABC_Country
)
 

  • move the join into a Derived Table (this could also be done for a MERGE)

UPDATE Staging.CDD_Today
SET ABC_Risk = b.riskfactor
FROM
 ( SELECT .... FROM Staging.CDD_TodayCDD_CountryRisk a
   LEFT JOIN dbo.CDD_ABC_Uplift b ON b.REVIEW_ID = a.REVIEW_ID
   AND b.COUNTRY_NAME = a.ABC_Country
) as b
WHERE ... 
 
Dieter
 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



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