回复 20楼 yd1954
先回答我的问题,看19楼的回复回复 21楼 吹水佬
n1 n5
80 11
80 22
80 33
98 44
这种情况的n1=80的下一行n5是不是:22、33、44
是
cDZ = "n1n5" dbfFile = cDZ + ".dbf" tmpFile = "tmp.dbf" COPY FILE (dbfFile) TO (tmpFile) USE (tmpFile) IN 0 ALIAS a USE (tmpFile) IN 0 ALIAS b AGAIN GO BOTTOM SCATTER FIELDS qihao,h1,h2,h3 TO arr SELECT a SET RELATION TO RECNO()+1 INTO "b" &&当前行与下一行关联 REPLACE ALL a.n5 WITH b.n5 &&将下一行的n5放到当前行的n5 SET RELATION TO SELECT n1,n5,COUNT(*) cnt FROM a WHERE BETWEEN(n1,80,188) GROUP BY n1,n5 INTO CURSOR t1 &&按n1n5分类统计记录数 SELECT arr[1] qihao, arr[2] h1, arr[3] h2, arr[4] h3, n1,cDZ zd,; MAX(n5) 最大值,; MIN(n5) 最小值,; SUM(cnt) 多少个值,; SUM(IIF(cnt==1,1,0)) 多少个不重复; FROM t1; GROUP BY n1; INTO CURSOR t2 READWRITE SELECT * FROM t2