I should use this approach more but it can be slower under some conditions
SELECT A.RetailerID, X.RetailerIDTheirs FROM TableA AS A CROSS APPLY (SELECT TOP 1 B.RetailerIDTheirs FROM TableB B WHERE B.RetailerID = A.RetailerID
ORDER BY B.RetailerIDTheirs ASC) AS X
No comments:
Post a Comment