㈠ sql查询问题 查询成绩分布情况
呵呵,你这是一堆的问题呀:
优秀、良好……各级别的(人数):
首先,假设你的分数是 百分制,优秀即高于85分等。。。。
因此:
select 课程,count(*) as 人数,‘优秀’ as 类别
from 成绩
where 分数>85
group by 课程
union
select 课程,count(*) as 人数,‘良好’ as 类别
from 成绩
where 分数>70 and 分数<=85
group by 课程
union
select 课程,count(*) as 人数,‘及格’ as 类别
from 成绩
where 分数>60 and 分数<=70
group by 课程
分布情况及百分比:
得根据上面的结果来再计算。
先弄个总人数的视图:select count(*) as 总人数 from 成绩
再计算百分比:
select 课程,人数/总人数*100% as 百分比 from 各级别人数 group by 课程,类别
其他的统计也就雷同了。
㈡ SQL Service数据查询操作 统计每门课程的选课人数及不及格人数
select c.cnum,
c.cname,
count(1) "选课人数",
sum(case
when sc.score < 60 then
1
else
0
end) "不及格人数"
from course c, sections s, sc
where s.cnum = c.cnum
and sc.secnum = s.secnum
group by c.cnum, c.cname
㈢ SQL查询 统计每门课的选课人数及不及格人数
select a.cnum,a.cname,a.rs,b.bjg_rs
from
(select sec.cnum,c.cname,count(s.snum) as 'rs'
from student s,course c,sc,sections sec
where s.snum = sc.snum and
sc.secnum = sec.secnum and
sec.cnum = c.cnum
group by sec.cnum,c.cname) a
left join
(select sec.cnum,c.cname,count(s.snum) as 'bjg_rs'
from student s,course c,sc,sections sec
where s.snum = sc.snum and
sc.secnum = sec.secnum and
sec.cnum = c.cnum and
sc.score < '60'
group by sec.cnum,c.cname) b
on a.cnum = b.cnum
㈣ SQL统计每门课程的不及格人数
你的要求有点特别,要求 学号!
如果只是
统计每门课程的不及格人数下面的SQL就可以啦:
select cnum,count(cnum) as 不及格人数
from sc
where score < 60
group by cnum 注意:是对课程号分组哟,楼上的是错的。
如果你要输出学号:
Select sc.snum as 学号,
a.cnum as 课程号,
a.不及格人数
From sc,
(select cnum,count(cnum) as 不及格人数
from sc
where score < 60
group by cnum) as a
where sc.score<60 and sc.cnum=a.cnum
以上我相信是没有问题的,你测试一下!
如果OK,给分哟
呵呵
㈤ SQL,将各门课程缺少考试成绩的学生查询出来
SELECTDISTINCT学生表.学生ID,姓名FROM学生表,成绩表
WHERE学生表.学生ID=成绩表.学生ID
AND成绩ISNULL;
㈥ oracle sql查询缺考的学生
select 学号, sum(课程一成绩, 课程二成绩, 课程三成绩) as 总成绩 from 表 where 总成绩 is null;
这样写试一下。
㈦ SQL语句求助,查询出每门课程及格和不及格的人数
---以下在SQL2005执行通过--
---结果将以 科目、及格数、不及格数 显示
select * from
(select col2,count(*) as [及格数]
from tb
where col1>=60
group by col2
)t
outer apply
(select count(*) as [不及格数]
from tb
where col1<60 and t.col2= col2
group by col2
)m
-----这应该是楼主想要的了吧。
㈧ SQL语句求助,查询出每门课程及格和不及格的人数
select a.score ,count as 人数 ,col2 as 科目 from
(select case when col1>=60 then '及格' else '不及格' end as score ,col2 from tb g )
a group by a.score,a.col2
㈨ SQL语句求助:统计各班每门课程成绩均不及格的同学人数
根据题目要求,简单分析可以知道,其实这条查询语句只使用“学生选课”和“学生”这两张表即可。此处应该使用“左连接”,用学生表中的班级字段进行“分组”,用COUNT()函数对分数小于60的同学的个数进行统计。
SELECT 学生.班级,COUNT(学生选课.成绩<60)
FROM 学生选课
LEFT JOIN 学生
ON 学生选课.学生ID=学生.学生ID
GROUP BY 学生.班级
你可以进行验证一下,如果不对,或者有更优化的方法,可以相互学习!
㈩ SQL 查询某门课程及格的总人数以及不及格的总人数以及没成绩的人数
1、创建测试表,
create table test_score(class_id varchar2(20), student_id varchar2(20), score number);