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
Hi Harpreet,
is this an actually update statement? (SQL Server?)
There's no condition to join to CDD_Today.
You might rewrite it:
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
)
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