有人帮忙看一下,怎么实现啊?
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.班级