-- 企 CREATE TABLE MEMBER( IDX int identity(1,1) , NAME Char(20) ) GO -- 一危 INSERT INTO MEMBER VALUES('A') INSERT INTO MEMBER VALUES('A') INSERT INTO MEMBER VALUES('B') INSERT INTO MEMBER VALUES('B') INSERT INTO MEMBER VALUES('B') INSERT INTO MEMBER VALUES('B') INSERT INTO MEMBER VALUES('C') INSERT INTO MEMBER VALUES('C') GO
--2000危 覯 DELETE FROM MEMBER WHERE IDX IN ( SELECT A.IDX as IDX FROM MEMBER A INNER JOIN ( SELECT MAX(IDX) AS IDX , NAME AS NAME , COUNT(*) AS CNT FROM MEMBER GROUP BY NAME HAVING COUNT(*) >1) B ON A.NAME = B.NAME AND A.IDX!=B.IDX )