以下是引用sylknb在2014-5-20 22:15:44的发言:
有多少科有多少条命令太不理想
不情愿“有多少科有多少条命令”的思路,那就用循环嘛
有多少科有多少条命令太不理想
只求每天有一丁点儿的进步就可以了
Select *,Space(100) km From ls2 Into Cursor Temp ReadWrite Local lcStr,lcStr1,lcStr2,lcStr3 Store "" To lcStr1,lcStr2,lcStr3 Scan nRow=Alines(Abkkm,报考科目,",") =Asort(Abkkm) lcStr="" For lnI=1 To nRow lcStr=lcStr+Alltrim(Abkkm[lnI])+Iif(lnI<nRow,",","") If Not Alltrim(Abkkm[lnI])$lcStr1 lcStr1=lcStr1+Iif(Empty(lcStr1),Alltrim(Abkkm[lnI]),","+Alltrim(Abkkm[lnI])) && 报考科目内容 EndIf Endfor lcStr2=lcStr2+Iif(Empty(lcStr2),lcStr,","+lcStr) && 报考全部内容 Replace km With lcStr Endscan For lnI=1 To Alines(Akms,lcStr1,",") lcStr3=lcStr3+Akms[lnI]+" = "+Padl(Occurs(Akms[lnI],lcStr2),4," ")+" 人"+Chr(13)+" "+Chr(13) EndFor Messagebox(lcStr3,0," 各科报考情况统计 ")
Select * From ls2 Into Cursor Temp Local lcBkkm,lcStr,lcStr1,lcStr2 Store "" To lcBkkm,lcStr,lcStr1,lcStr2 Scan lnRow=Alines(Abkkm,报考科目,",") For lnI=1 To lnRow If Not Alltrim(Abkkm[lnI])$lcBkkm lcBkkm=lcBkkm+Iif(Empty(lcBkkm),Alltrim(Abkkm[lnI]),","+Alltrim(Abkkm[lnI])) && 报考科目内容 EndIf Endfor EndScan lnRow=Alines(Abkkm,lcBkkm,",") For lnI=1 To lnRow lcStr=lcStr+'"'+Space(10)+'" '+Abkkm[lnI]+Iif(lnI<lnRow,",","") lcStr1=lcStr1+"Cast(Sum(Iif(Alltrim(&Abkkm[lnI])=='"+Alltrim(Abkkm[lnI])+"',1,0)) As N(4)) "+Alltrim(Abkkm[lnI])+Iif(lnI<lnRow,",","") lcStr2=lcStr2+"Sum("+Abkkm[lnI]+")"+Iif(lnI<lnRow,",","") Endfor Select *,&lcStr From ls2 Order By 报名点代码 Into Cursor Temp ReadWrite Scan For lnI=3 To Alines(Abkkm,报考科目,",")+2 Replace Record Recno() (Abkkm[lnI-2]) With Abkkm[lnI-2] EndFor Endscan Select 报名点代码,&lcStr1,00000 小计 From Temp Group By 报名点代码 Into Cursor Tj ReadWrite Insert Into Tj Select "合计",&lcStr2,0 From Tj lcStr="" For lnI=2 To Fcount()-1 lcStr=lcStr+Field(lnI)+Iif(lnI<Fcount()-1,"+","") EndFor Replace All (Field(Fcount())) With &lcStr Browse