SELECT 9
SELECT fb
a=messagebox("真的要分班吗?",4+32+256,"系统提示")
IF a=6
GO top
SELECT xz,zymc,COUNT(*) as id FROM fb INTO table t1 GROUP BY xz,zymc
*汇总各专业学制人数分配给id1
SELECT *,RECNO() qq FROM (SELECT * FROM t1 ORDER BY xz,zymc) a INTO table t2
*给各专业学制分配一个序号到qq字段
UPDATE fb SET fb.qq=t2.qq from t2 WHERE fb.xz=t2.xz AND fb.zymc=t2.zymc
*将t2表中qq的值赋给fb表中的qq
SELECT fb
IF qq=1
*我想实现当qq=1的时候 count统计学制专业数赋给a,用a来判断分班,50人为一班,排序为蛇型(1,2,3,4,4,3,2,1)
COUNT for xz=fb.xz and zymc=fb.zymc
AND qq=fb.qq to a
a=iif(a%50>0,int(a/50)+1,a/50)
IF a<=1
replace bj with "2014级"+ALLTRIM(zymc)+alltrim(xz)+"年"+"班"
ELSE
set filt to xz=ALLTRIM(xz) and zymc=ALLTRIM(zymc)
go top
do while .T.
for n=1 to a
replace bj with "2014级"+ALLTRIM(zymc)+alltrim(xz)+"年"+ALLTRIM(STR(n))+"班"
SKIP
if eof()
return
endif
ENDFOR
for m=a to 1 step -1
replace bj with "2014级"+ALLTRIM(zymc)+alltrim(xz)+"年"+ALLTRIM(STR(m))+"班"
SKIP
if eof()
return
ENDIF
ENDFOR
ENDDO
qq=qq+1
ENDIF
ENDIF
endif
现在出来的是从第一个排序1-19,19-1这样的大循环