请大神指点如何精简下面这段代码,提高效率?
程序代码:
UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3702') from qx WHERE sx.xxdm='3702' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3702' AND qx.sx>=127) from qx WHERE sx.xxdm='3702' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3702' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3702' AND qx.sx>=90) from qx WHERE sx.xxdm='3702' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3702' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3702') from qx WHERE sx.xxdm='3702' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3703') from qx WHERE sx.xxdm='3703' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3703' AND qx.sx>=127) from qx WHERE sx.xxdm='3703' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3703' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3703' AND qx.sx>=90) from qx WHERE sx.xxdm='3703' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3703' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3703') from qx WHERE sx.xxdm='3703' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3704') from qx WHERE sx.xxdm='3704' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3704' AND qx.sx>=127) from qx WHERE sx.xxdm='3704' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3704' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3704' AND qx.sx>=90) from qx WHERE sx.xxdm='3704' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3704' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3704') from qx WHERE sx.xxdm='3704' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3705') from qx WHERE sx.xxdm='3705' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3705' AND qx.sx>=127) from qx WHERE sx.xxdm='3705' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3705' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3705' AND qx.sx>=90) from qx WHERE sx.xxdm='3705' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3705' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3705') from qx WHERE sx.xxdm='3705' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3706') from qx WHERE sx.xxdm='3706' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3706' AND qx.sx>=127) from qx WHERE sx.xxdm='3706' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3706' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3706' AND qx.sx>=90) from qx WHERE sx.xxdm='3706' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3706' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3706') from qx WHERE sx.xxdm='3706' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3707') from qx WHERE sx.xxdm='3707' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3707' AND qx.sx>=127) from qx WHERE sx.xxdm='3707' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3707' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3707' AND qx.sx>=90) from qx WHERE sx.xxdm='3707' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3707' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3707') from qx WHERE sx.xxdm='3707' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3708') from qx WHERE sx.xxdm='3708' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3708' AND qx.sx>=127) from qx WHERE sx.xxdm='3708' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3708' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3708' AND qx.sx>=90) from qx WHERE sx.xxdm='3708' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3708' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3708') from qx WHERE sx.xxdm='3708' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3709') from qx WHERE sx.xxdm='3709' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3709' AND qx.sx>=127) from qx WHERE sx.xxdm='3709' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3709' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3709' AND qx.sx>=90) from qx WHERE sx.xxdm='3709' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3709' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3709') from qx WHERE sx.xxdm='3709' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3710') from qx WHERE sx.xxdm='3710' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3710' AND qx.sx>=127) from qx WHERE sx.xxdm='3710' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3710' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3710' AND qx.sx>=90) from qx WHERE sx.xxdm='3710' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3710' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3710') from qx WHERE sx.xxdm='3710' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3711') from qx WHERE sx.xxdm='3711' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3711' AND qx.sx>=127) from qx WHERE sx.xxdm='3711' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3711' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3711' AND qx.sx>=90) from qx WHERE sx.xxdm='3711' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3711' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3711') from qx WHERE sx.xxdm='3711' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3712') from qx WHERE sx.xxdm='3712' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3712' AND qx.sx>=127) from qx WHERE sx.xxdm='3712' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3712' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3712' AND qx.sx>=90) from qx WHERE sx.xxdm='3712' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3712' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3712') from qx WHERE sx.xxdm='3712' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3713') from qx WHERE sx.xxdm='3713' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3713' AND qx.sx>=127) from qx WHERE sx.xxdm='3713' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3713' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3713' AND qx.sx>=90) from qx WHERE sx.xxdm='3713' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3713' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3713') from qx WHERE sx.xxdm='3713' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3714') from qx WHERE sx.xxdm='3714' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3714' AND qx.sx>=127) from qx WHERE sx.xxdm='3714' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3714' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3714' AND qx.sx>=90) from qx WHERE sx.xxdm='3714' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3714' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3714') from qx WHERE sx.xxdm='3714' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3715') from qx WHERE sx.xxdm='3715' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3715' AND qx.sx>=127) from qx WHERE sx.xxdm='3715' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3715' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3715' AND qx.sx>=90) from qx WHERE sx.xxdm='3715' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3715' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3715') from qx WHERE sx.xxdm='3715' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3716') from qx WHERE sx.xxdm='3716' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3716' AND qx.sx>=127) from qx WHERE sx.xxdm='3716' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3716' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3716' AND qx.sx>=90) from qx WHERE sx.xxdm='3716' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3716' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3716') from qx WHERE sx.xxdm='3716' UPDATE sx SET zxss=(select COUNT(*) from qx WHERE qx.xxdm='3717') from qx WHERE sx.xxdm='3717' UPDATE sx SET yxrs=(select COUNT(*) from qx WHERE qx.xxdm='3717' AND qx.sx>=127) from qx WHERE sx.xxdm='3717' UPDATE sx SET yxl=yxrs/zxss*100 WHERE xxdm='3717' UPDATE sx SET jgrs=(select COUNT(*) from qx WHERE qx.xxdm='3717' AND qx.sx>=90) from qx WHERE sx.xxdm='3717' UPDATE sx SET jgl=jgrs/zxss*100 WHERE xxdm='3717' UPDATE sx SET dkzf=(select sum(sx) from qx WHERE qx.xxdm='3717') from qx WHERE sx.xxdm='3717' UPDATE sx SET pjf=dkzf/zxss UPDATE sx SET pjfl=dkzf/zxss UPDATE sx SET zhb=yxl*0.3+jgl*0.4+pjfl*0.3 UPDATE sx SET pm=b.pm from (SELECT zhb,RECNO() pm FROM (SELECT distinct zhb FROM sx ORDER BY zhb DESC) a) b WHERE sx.zhb=b.zhb这段代码是计算qx表中数学成绩情况表,我用这些代码可以执行,但好像太长了,有没有什么办法可以把这些代码精简,提高效率?qx表和数学表如下:
数据表.zip
(102.96 KB)
[此贴子已经被作者于2016-6-4 09:59编辑过]