求教:统计各校各科优秀良好合格人数(率)
求教:有成绩表,想统计出各校各学科优秀、良好、及格率(或者人数也可以),但没想出如何用循环方法实现自动统计(虽然做过类似请教,也爬论坛,但是只会逐句用count统计,没学会简洁的循环语句统计)
zcj.zip
(254.91 KB)
*--*创建各科优秀良好及格段次表
CREATE CURSOR bz (km c(10), n1 N(6, 2), n2 N(6, 2), n3 N(6, 2))
INSERT INTO bz VALUES ("语文", 90,105,120)
INSERT INTO bz VALUES ("数学", 90,105,120)
INSERT INTO bz VALUES ("英语", 90,105,120)
INSERT INTO bz VALUES ("物理", 60,70,80)
INSERT INTO bz VALUES ("化学", 60,70,80)
INSERT INTO bz VALUES ("政治", 60,70,80)
INSERT INTO bz VALUES ("历史", 60,70,80)
INSERT INTO bz VALUES ("地理", 60,70,80)
INSERT INTO bz VALUES ("生物", 60,70,80)
&&&BROWSE
SELECT n1, n2,n3 FROM bz INTO ARRAY abz
USE zcj IN 0
*--*创建统计表结构
SELECT km FROM bz INTO ARRAY arr_km
SELECT DISTINCT czxxdm FROM zcj ORDER BY czxxdm INTO ARRAY arr_czxxdm
cmd = "CREATE CURSOR tt (czxxdm c(8),zrs I"
FOR i=1 TO ALEN(arr_km)
cmd = cmd + "," + "优" + arr_km[i] + " n(6,2)" + "," + "良" + arr_km[i] + " n(6,2)" + "," + "及" + arr_km[i] + " n(6,2)"
ENDFOR
cmd = cmd + ")"
EXECSCRIPT(cmd)
APPEND FROM ARRAY arr_czxxdm
BROWSE
*--*计算统计各校各科优秀良好合格人数??
[此贴子已经被作者于2023-10-12 12:49编辑过]