回复 20楼 吹水佬
有重复时返回到本级循环(不写入),重新搜索,等到无重复才写入并继续循环搜索(我这句“返回到本级循环”不知用词是否正确)[ 本帖最后由 fdxxhjc 于 2015-5-25 14:16 编辑 ]
CLEAR ALL SET SAFETY off CREATE TABLE tmp(sz n) INSERT INTO tmp(sz) VALUES (1) INSERT INTO tmp(sz) VALUES (2) INSERT INTO tmp(sz) VALUES (3) INSERT INTO tmp(sz) VALUES (4) INSERT INTO tmp(sz) VALUES (5) INSERT INTO tmp(sz) VALUES (6) INSERT INTO tmp(sz) VALUES (7) INSERT INTO tmp(sz) VALUES (8) INSERT INTO tmp(sz) VALUES (9) INSERT INTO tmp(sz) VALUES (10) INSERT INTO tmp(sz) VALUES (11) INSERT INTO tmp(sz) VALUES (12) &&获取组合 SELECT a.sz as sz1,b.sz as sz2,c.sz as sz3 FROM tmp a INNER JOIN tmp b ON a.sz<b.sz INNER JOIN tmp c ON b.sz<c.sz WHERE a.sz+b.sz+c.sz=26 INTO CURSOR AAA SELECT a.sz as sz4,b.sz as sz5,c.sz as sz6,d.sz as sz7 FROM tmp a INNER JOIN tmp b ON a.sz<b.sz INNER JOIN tmp c ON b.sz<c.sz INNER JOIN tmp d ON c.sz<d.sz WHERE a.sz+b.sz+c.sz+d.sz=26 INTO CURSOR BBB SELECT a.sz as sz8,b.sz as sz9,c.sz as sz10,d.sz as sz11,e.sz as sz12 FROM tmp a INNER JOIN tmp b ON a.sz<b.sz INNER JOIN tmp c ON b.sz<c.sz INNER JOIN tmp d ON c.sz<d.sz INNER JOIN tmp e ON d.sz<e.sz WHERE a.sz+b.sz+c.sz+d.sz+e.sz=26 INTO CURSOR CCC SELECT RECNO() as xh,* FROM (SELECT * FROM aaa,bbb,ccc)a INTO CURSOR ttt &&过滤 SELECT xh from(; SELECT xh,sz1 as sz FROM ttt; union all; SELECT xh,sz2 as sz FROM ttt; union all; SELECT xh,sz3 as sz FROM ttt; union all; SELECT xh,sz4 as sz FROM ttt; union all; SELECT xh,sz5 as sz FROM ttt; union all; SELECT xh,sz6 as sz FROM ttt; union all; SELECT xh,sz7 as sz FROM ttt; union all; SELECT xh,sz8 as sz FROM ttt; union all; SELECT xh,sz9 as sz FROM ttt; union all; SELECT xh,sz10 as sz FROM ttt; union all; SELECT xh,sz11 as sz FROM ttt; union all; SELECT xh,sz12 as sz FROM ttt)a GROUP BY xh,sz HAVING COUNT(*)>=2 INTO CURSOR zzz SELECT sz1,sz2,sz3,sz4,sz5,sz6,sz7,sz8,sz9,sz10,sz11,sz12 FROM ttt a WHERE a.xh NOT in(SELECT xh FROM zzz)