求计算各科平均分,要求每班各科取从高到低的90%参与计算平均分,及平均分的各科班级名次分布。
求计算各科平均分,要求每班各科取从高到低的90%参与计算平均分,及平均分的各科班级名次分布。[此贴子已经被作者于2019-11-11 16:55编辑过]
CLOSE DATABASES SELECT DISTINCT 班级 FROM 学校 INTO CURSOR bj SELECT 学校 nRows = AFIELDS(abj) LOCAL akm[nRows - 3] * 生成科目数组 FOR i = 4 TO nrows akm[i - 3] = abj[i, 1] ENDFOR * 创建平均分名次临时表 cStr = "班级 C(2)" FOR i = 1 TO ALEN(akm) cStr = cStr + "," + akm[i] + "均分 N(6, 2)," + akm[i] + "名次 N(2)" ENDFOR CREATE CURSOR jfmc (&cStr) * 统计各科平均分 SELECT bj SCAN INSERT INTO jfmc (班级) VALUES (bj.班级) FOR i = 1 TO ALEN(akm) SELECT TOP 90 PERCENT 班级, &akm[i] FROM 学校 WHERE 班级 == bj.班级 ORDER BY &akm[i] DESC INTO CURSOR tt CALCULATE AVG(&akm[i]) TO nAvg REPLACE (akm[i] + "均分") WITH nAvg IN jfmc ENDFOR ENDSCAN * 统计各科平均分名次 SELECT jfmc FOR i = 1 TO ALEN(akm) cjf = akm[i] + "均分" INDEX ON 1000 - &cjf TAG cj nmc = 1 njf = 0 nrs = 1 SCAN IF &cjf != njf nmc = nrs ENDIF REPLACE (akm[i] + "名次") WITH nmc njf = &cjf nrs = nrs + 1 ENDSCAN ENDFOR SET ORDER TO GO TOP BROWSE