Exemplo de FIDDLE SQL
1) Use o CTE para obter o registro do valor máximo do código de envio com base em ARDivisionNo, CustomerNopara cada cliente
WITH cte AS (
SELECT*,
row_number() OVER(PARTITION BY ARDivisionNo, CustomerNo ORDER BY ShipToCode desc) AS [rn]
FROM t
)
Select * from cte WHERE [rn] = 1
2) Para excluir o registro, use Excluir consulta em vez de Selecionar e altere a cláusula Where para rn> 1. Exemplo de SQL FIDDLE
WITH cte AS (
SELECT*,
row_number() OVER(PARTITION BY ARDivisionNo, CustomerNo ORDER BY ShipToCode desc) AS [rn]
FROM t
)
Delete from cte WHERE [rn] > 1;
select * from t;