作者在 2015-03-14 21:17:38 发布以下内容
Set Collate To "MACHINE"
Set Talk Off
T1=Seconds()
Clear
Close DataBases
Local Akm[2],Apm[7],Afs[2,7],TableName[2],cXbm
cXbm="校编码"
TableName[1]="成绩"
TableName[2]="成绩分析"
Akm[1]="语文"
Akm[2]="数学"
Apm[1]=1
Apm[2]=50
Apm[3]=100
Apm[4]=200
Apm[5]=300
Apm[6]=400
Apm[7]=500
Select 0
Use (TableName[2])
Zap
Select 0
Use (TableName[1])
Index On &cXbm To bm UNIQUE
Copy To bm fields (cXbm)
Set Index To
* 获取前N名分数
For lnI=1 To Alen(Akm)
* Num=0
Sort To px On &Akm[lnI] /D
Select 0
Use px
For lnJ=1 To Alen(Apm)
Go Apm[lnJ]
* Num=Num+1
Afs[lnI,lnJ]=Evaluate(Akm[lnI])
EndFor
Use In px
Select (TableName[1])
EndFor
*---------------------------------------
* 数据处理
Select 0
Use bm
For lnI=1 To Alen(Akm)
Local Azd[11]
Azd[1]=Akm[lnI]
Azd[2]=""
Azd[3]=""
Azd[4]="有效分"
For lnII=1 TO Alen(Apm)
Azd[lnII+4]=Afs[lnI,lnII]
EndFor
Insert Into (TableName[2]) From Array Azd
Select bm
Scan
lcXbm=Evaluate(cXbm)
Local Ars[11]
Select (TableName[1])
* Index On Evaluate(cXbm)+Str(200-Evaluate(Akm[lnI])) To bm
Count To nZrs For Evaluate(cXbm)==lcXbm
Ars[1]="" &&Akm[lnI]
Ars[2]=lcXbm
Ars[3]=Transform(nZrs)
Ars[4]=""
For lnJ=1 To Alen(Apm)
Count To Ars[lnJ+4] For Evaluate(cXbm)==lcXbm And Evaluate(Akm[lnI])>=Afs[lnI,lnJ]
EndFor
Insert Into (TableName[2]) From Array Ars
EndScan
EndFor
*-----------*
MessageBox("共运行 "+Transform(Seconds()-T1)+" 秒")
select (TableName[2])
browse
Clear All
Close DataBases
Erase px.dbf
Erase bm.idx