Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

对学生各学科分数的分类统计

renjingzhou  发表于:2015-05-14 08:25:01  
复制

请大师们将下图

用sql语句制作出如下效果:

注意,最好不使用做报表的方式去设计。

 

 

 

Top
易勋 发表于:2015-05-14 08:49:10

直接用窗体将这些表格用文本框控件设计出来,并在每个文本框的控件来源给他写上代码即可或者新增一个按钮,在按钮的单击事件里写上赋值的代码

比如:me.txt语文平均分=Dsum(语文http://www.accessoft.com/article-show.asp?id=7436)/Dcounthttp://www.accessoft.com/article-show.asp?id=1748



煮江品茶 发表于:2015-05-14 09:46:46
select 1 as 序号,"平均分" as 统计项目,avg(a.语文) as 语文,avg(a.数学) as 数学,avg(a.英语) as 英语
from 成绩表 as a
union all
select 2 as 序号,"及格率" as 统计项目,(select count(*) from 成绩表 where 语文>=60)/count(*) as 语文,(select count(*) from 成绩表 where 数学>=60)/count(*) as 数学,(select count(*) from 成绩表 where 英语>=60)/count(*) as 英语
union all
select 3 as 序号,"优秀率" as 统计项目,(select count(*) from 成绩表 where 语文>=90)/count(*) as 语文,(select count(*) from 成绩表 where 数学>=90)/count(*) as 数学,(select count(*) from 成绩表 where 英语>=90)/count(*) as 英语
union all
select 4 as 序号,"90分以上" as 统计项目,(select count(*) from 成绩表 where 语文>=90) as 语文,(select count(*) from 成绩表 where 数学>=90) as 数学,(select count(*) from 成绩表 where 英语>=90) as 英语
union all
select 5 as 序号,"80~89分" as 统计项目,(select count(*) from 成绩表 where 语文>=80 and 语文<90) as 语文,(select count(*) from 成绩表 where 数学>=80 and 数学<90) as 数学,(select count(*) from 成绩表 where 英语>=80 and 英语<90) as 英语
union all
select 6 as 序号,"70~79分" as 统计项目,(select count(*) from 成绩表 where 语文>=70 and 语文<80) as 语文,(select count(*) from 成绩表 where 数学>=70 and 数学<80) as 数学,(select count(*) from 成绩表 where 英语>=70 and 英语<80) as 英语
union all
select 7 as 序号,"60~69分" as 统计项目,(select count(*) from 成绩表 where 语文>=60 and 语文<70) as 语文,(select count(*) from 成绩表 where 数学>=60 and 数学<70) as 数学,(select count(*) from 成绩表 where 英语>=60 and 英语<70) as 英语
union all
select 6 as 序号,"60分以下" as 统计项目,(select count(*) from 成绩表 where 语文<60) as 语文,(select count(*) from 成绩表 where 数学<60) as 数学,(select count(*) from 成绩表 where 英语<60) as 英语
union all
select 7 as 序号,"最高分" as 统计项目,max(a.语文) as 语文,max(a.数学) as 数学,max(a.英语) as 英语
from 成绩表 as a
union all
select 8 as 序号,"最低分" as 统计项目,min(a.语文) as 语文,min(a.数学) as 数学,min(a.英语) as 英语
from 成绩表 as a


杜超 发表于:2015-05-16 13:29:00

用Select Case进行分数区分

Select Case与Elseif用法示例-入门篇[Access软件网]
http://www.accessoft.com/article-show.asp?id=8114



总记录:3篇  页次:1/1 9 1 :