SELECT Old_Code, New_Code, IsNull(MAX(New_Code) OVER (PARTITION BY Old_Code), Old_Code) As Required_Code FROM t ;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)