求助贴,根据表内数据的条件,重新计算赋值
这是dbf文件
第一行是字段名
请教一下如果要实现 “调整后数据”这个字段里面的值该怎么写?
把每个班里面所有的“班级平均数”加起来以后,除以这个班里面“reason”字段不为‘1’的记录条数
如1班里面有10个人,reason=‘1’的有2个人,那么最后“调整后数据”的值就是70*10/8=87.5
SET ENGINEBEHAVIOR 70 Create Cursor Temp (班级 C(4), 班级平均数 n(4), reason n(4),调整后数据 n(6)) Insert Into Temp Values ("1班", 70, 0 ,0) Insert Into Temp Values ("1班", 70, 0 ,0) Insert Into Temp Values ("1班", 70, 1 ,0) Insert Into Temp Values ("1班", 70, 1 ,0) Insert Into Temp Values ("1班", 70, 2 ,0) Insert Into Temp Values ("1班", 70, 2 ,0) Insert Into Temp Values ("1班", 70, 3 ,0) Insert Into Temp Values ("1班", 70, 3 ,0) Insert Into Temp Values ("1班", 70, 4 ,0) Insert Into Temp Values ("1班", 70, 5 ,0) Insert Into Temp Values ("2班", 85, 0 ,0) Insert Into Temp Values ("2班", 85, 0 ,0) Insert Into Temp Values ("2班", 85, 1 ,0) Insert Into Temp Values ("2班", 85, 1 ,0) Insert Into Temp Values ("2班", 85, 0 ,0) Insert Into Temp Values ("2班", 85, 0 ,0) Insert Into Temp Values ("2班", 85, 0 ,0) sele 班级,sum(班级平均数) 参数1 ,SUM(IIF(reason<>1,1,0)) 参数2 from temp grou by 班级 into curs a1 sele temp.班级, temp.班级平均数, temp.reason, ROUND(a1.参数1/a1.参数2,1) 调整后数据 from temp,a1 where temp.班级 = a1.班级