程序代码:
CREATE TABLE T (A I,B C(2),C C(3)) INSERT INTO T VALUES (1,[AA],[BB1]) INSERT INTO T VALUES (2,[AA],[BB2]) INSERT INTO T VALUES (3,[CC],[BB3]) INSERT INTO T VALUES (4,[AA],[BB4]) INSERT INTO T VALUES (5,[CC],[BB5]) INSERT INTO T VALUES (6,[BB],[BB6]) INSERT INTO T VALUES (7,[DD],[BB7]) * 1. 删除重复的记录行 SELECT * FROM T WHERE B IN (SELECT B FROM T GROUP BY B HAVING COUNT(B)=1) INTO ARRAY TT SELECT T ZAP APPEND FROM ARRAY TT BROWSE * 2. 保留重复的记录行中的一条记录 * A. 保留 A 字段值最小的那条记录 SELECT * FROM T WHERE B IN (SELECT B FROM T GROUP BY B HAVING COUNT(B)=1) INTO ARRAY TT DELETE FROM T WHERE A NOT IN (SELECT MIN(A) FROM T GROUP BY B HAVING COUNT(B)>1) SELECT T PACK APPEND FROM ARRAY TT BROWSE * B. 保留 A 字段值最大的那条记录 SELECT * FROM T WHERE B IN (SELECT B FROM T GROUP BY B HAVING COUNT(B)=1) INTO ARRAY TT DELETE FROM T WHERE A NOT IN (SELECT MAX(A) FROM T GROUP BY B HAVING COUNT(B)>1) SELECT T PACK APPEND FROM ARRAY TT BROWSE
坚守VFP最后的阵地