计算各科平均分
在全校成绩总排名表中,计算出各班的各科(语文数学英语等)平均分(前20名平均分的40%+总人数的60%)
* VFP9代码 CLOSE DATABASES ALL cStr="班级,总分,语文,数学,英语,物理,化学,生物,历史,地理,政治" =ALINES(azd,cStr,",") LIST MEMORY LIKE azd cField="班级 C(2),总分 N(7,2)" FOR i=3 TO ALEN(azd,1) cField=cField+","+azd[i]+" N(6,2)" ENDFOR SELECT distinct 班级 FROM 学校 INTO ARRAY abj CREATE CURSOR 平均分 (&cfield) APPEND FROM ARRAY ABJ INDEX ON 班级 TO px FOR i=2 TO ALEN(azd,1) SELECT 班级,AVG(&azd[i]) AS cj FROM 学校 GROUP BY 1 INTO CURSOR qb SET RELATION TO 班级 INTO 平均分 SELECT qb SCAN REPLACE (azd[i]) WITH qb.cj IN 平均分 ENDSCAN SELECT 班级,&azd[i] as cj FROM 学校 xx WHERE 20>(SELECT COUNT(*) FROM 学校 WHERE 班级=xx.班级 AND &azd[i] > xx.&azd[i] ) ORDER BY 班级,2 DESC INTO CURSOR q20 SELECT 班级,AVG(cj) AS cj FROM q20 GROUP BY 1 INTO CURSOR q20 SET RELATION TO 班级 INTO 平均分 SCAN REPLACE (azd[i]) WITH EVALUATE(azd[i])*0.6+q20.cj*0.4 IN 平均分 ENDSCAN ENDFOR SET RELATION TO SELECT 平均分 SET INDEX TO BROWSE CLOSE DATABASES ALL ERASE px.idx