Thanks for the sample data. Next time (if you would please) try to provide it in a way similar to what I've done. This will, in more complex questions, save a ton of time. Plus some people won't even answer questions without it. :-)
At any rate, here's a solution for you.
DECLARE @test TABLE
(10, '15066-00266-01', 10053357)
,(96, '15066-00266-01', 10048778)
,(10, '19200-00027-06', 10052915)
,(96, '19200-00027-06', 0)
,COALESCE(NULLIF(t1.PlannerCode,0),t2.PlannerCode) AS derived_PlannerCode
@test AS t1
LEFT JOIN @test AS t2
ON t1.ItemCode = t2.ItemCode
AND t2.CompanyCode <> 96
t1.CompanyCode = 96
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE
you'll likely increase the number and quality of responses you get to your question.Jason L. Selburg