试了一下用 REPLACE ...... ALL 大概27秒左右
测试环境:
CPU: Core i5-3470 3.2G 4核
RAM:4G
OS:Windows 10 专业版 32位
VFP:9.0
测试数据:
* 生成双色球原始数据表
CREATE CURSOR t1 (x c(2))
FOR i=1 TO 33
INSERT INTO t1 VALUES (PADL(i,2,"0"))
ENDFOR
SELECT a.x h1,b.x h2,c.x h3,d.x h4,e.x h5,f.x h6,SPACE(10) hh FROM t1 a;
INNER JOIN t1 b ON b.x>a.x ;
INNER JOIN t1 c ON c.x>b.x ;
INNER JOIN t1 d ON d.x>c.x ;
INNER JOIN t1 e ON e.x>d.x ;
INNER JOIN t1 f ON f.x>e.x ORDER BY 1,2,3,4,5,6 INTO TABLE ssq
CLOSE DATABASES ALL
RETURN
测试代码:
USE ssq
PRIVATE hh1, hh2, hh3
s1 = SECONDS()
REPLACE hh WITH _fun() ALL
? SECONDS() - s1
GO TOP
BROWSE
FUNCTION _fun()
STORE 0 TO hh1, hh2, hh3
hh1 = hh1 + IIF(BETWEEN(h1,"01","11"),1,0) + ;
IIF(BETWEEN(h2,"01","11"),1,0) + ;
IIF(BETWEEN(h3,"01","11"),1,0) + ;
IIF(BETWEEN(h4,"01","11"),1,0) + ;
IIF(BETWEEN(h5,"01","11"),1,0) + ;
IIF(BETWEEN(h6,"01","11"),1,0)
hh2 = hh2 + IIF(BETWEEN(h1,"12","22"),1,0) + ;
IIF(BETWEEN(h2,"12","22"),1,0) + ;
IIF(BETWEEN(h3,"12","22"),1,0) + ;
IIF(BETWEEN(h4,"12","22"),1,0) + ;
IIF(BETWEEN(h5,"12","22"),1,0) + ;
IIF(BETWEEN(h6,"12","22"),1,0)
hh3 = hh3 + IIF(BETWEEN(h1,"23","33"),1,0) + ;
IIF(BETWEEN(h2,"23","33"),1,0) + ;
IIF(BETWEEN(h3,"23","33"),1,0) + ;
IIF(BETWEEN(h4,"23","33"),1,0) + ;
IIF(BETWEEN(h5,"23","33"),1,0) + ;
IIF(BETWEEN(h6,"23","33"),1,0)
RETURN STR(hh1,1)+":"+STR(hh2,1)+":"+STR(hh3,1)
ENDFUNC
测试环境:
CPU: Core i5-3470 3.2G 4核
RAM:4G
OS:Windows 10 专业版 32位
VFP:9.0
测试数据:
* 生成双色球原始数据表
CREATE CURSOR t1 (x c(2))
FOR i=1 TO 33
INSERT INTO t1 VALUES (PADL(i,2,"0"))
ENDFOR
SELECT a.x h1,b.x h2,c.x h3,d.x h4,e.x h5,f.x h6,SPACE(10) hh FROM t1 a;
INNER JOIN t1 b ON b.x>a.x ;
INNER JOIN t1 c ON c.x>b.x ;
INNER JOIN t1 d ON d.x>c.x ;
INNER JOIN t1 e ON e.x>d.x ;
INNER JOIN t1 f ON f.x>e.x ORDER BY 1,2,3,4,5,6 INTO TABLE ssq
CLOSE DATABASES ALL
RETURN
测试代码:
USE ssq
PRIVATE hh1, hh2, hh3
s1 = SECONDS()
REPLACE hh WITH _fun() ALL
? SECONDS() - s1
GO TOP
BROWSE
FUNCTION _fun()
STORE 0 TO hh1, hh2, hh3
hh1 = hh1 + IIF(BETWEEN(h1,"01","11"),1,0) + ;
IIF(BETWEEN(h2,"01","11"),1,0) + ;
IIF(BETWEEN(h3,"01","11"),1,0) + ;
IIF(BETWEEN(h4,"01","11"),1,0) + ;
IIF(BETWEEN(h5,"01","11"),1,0) + ;
IIF(BETWEEN(h6,"01","11"),1,0)
hh2 = hh2 + IIF(BETWEEN(h1,"12","22"),1,0) + ;
IIF(BETWEEN(h2,"12","22"),1,0) + ;
IIF(BETWEEN(h3,"12","22"),1,0) + ;
IIF(BETWEEN(h4,"12","22"),1,0) + ;
IIF(BETWEEN(h5,"12","22"),1,0) + ;
IIF(BETWEEN(h6,"12","22"),1,0)
hh3 = hh3 + IIF(BETWEEN(h1,"23","33"),1,0) + ;
IIF(BETWEEN(h2,"23","33"),1,0) + ;
IIF(BETWEEN(h3,"23","33"),1,0) + ;
IIF(BETWEEN(h4,"23","33"),1,0) + ;
IIF(BETWEEN(h5,"23","33"),1,0) + ;
IIF(BETWEEN(h6,"23","33"),1,0)
RETURN STR(hh1,1)+":"+STR(hh2,1)+":"+STR(hh3,1)
ENDFUNC