| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2268 人关注过本帖
标题:请大神指点如何精简下面这段代码,提高效率?
取消只看楼主 加入收藏
hguyy
Rank: 2
等 级:论坛游民
帖 子:56
专家分:20
注 册:2016-1-25
结帖率:83.33%
收藏
已结贴  问题点数:9 回复次数:4 
请大神指点如何精简下面这段代码,提高效率?
程序代码:
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编辑过]

搜索更多相关主题的帖子: color 如何 
2016-06-04 09:55
hguyy
Rank: 2
等 级:论坛游民
帖 子:56
专家分:20
注 册:2016-1-25
收藏
得分:0 
回复 9楼 aaaaaa
太感谢你了
2016-06-04 21:29
hguyy
Rank: 2
等 级:论坛游民
帖 子:56
专家分:20
注 册:2016-1-25
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册
这是相应的字段名
2016-06-04 21:34
hguyy
Rank: 2
等 级:论坛游民
帖 子:56
专家分:20
注 册:2016-1-25
收藏
得分:0 
回复 5楼 aaaaaa
你才的字段名都是对了
2016-06-04 21:36
hguyy
Rank: 2
等 级:论坛游民
帖 子:56
专家分:20
注 册:2016-1-25
收藏
得分:0 
回复 14楼 aaaaaa
对的,平均分和平均分率是一样的
2016-06-05 22:07
快速回复:请大神指点如何精简下面这段代码,提高效率?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035762 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved