by ssi
21. February 2016 12:05
DELETE FROM [ssi_tbl_NameAddress]
WHERE control NOT IN (SELECT MAX(control)
FROM [ssi_tbl_NameAddress]
GROUP BY Lname,fname
/*Even if ID is not null-able SQL Server treats MAX(ID) as potentially
nullable. Because of semantics of NOT IN (NULL) including the clause
below can simplify the plan*/
HAVING MAX(control) IS NOT NULL)
4814dad4-0146-454d-834c-9ff9548c9c14|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: sql
SQL