帕萨特怎样用u盘听歌u盘mp3怎么播放

怎样用SQL语句表示:查询每个班级的学生人数 QL语句 怎么找出学生表中各班的人_微博生活网
你目前正在浏览:& > &
怎样用SQL语句表示:查询每个班级的学生人数
怎样用SQL语句表示:查询每个班级的学生人数
select 班级号,count(*) from 学生表 group by 班级号 不知道您的表是什么样的
如用Oracle数据库create table student(
stuid number not null primary key,
stusex char(2) not null,
stuname varchar2(20) not null,
stuage number not null
select 班级,count(1) as 人数 from 学生表 group by 班级
怎样用SQL语句表示:查询每个班级的学生人数 ……
SELECT Cno ,COUNT(*) AS 人数 --统计FROM StudentsGROUP ...SQL语句 怎么找出学生表中各班的人数阿 ……
5、 统计出每个班级的人数,用SQL语句 3
怎样用S...有学生和班级两张表,如何用一条sql语句查询学生人数最多的班级信息? ……
select top 1 max(学生ID) as result from 学生, 班级 where...SQL语句统计班级人数,班级表+学生表 ……
SELECT 班级名称,COUNT(学号) 人数 FROM 班级表 LEFT JOIN 学生表 ON...5、 统计出每个班级的人数,用SQL语句 ……
select count(学生ID) from 表名 group by 班级名
hqzxzb | ...sql语句 查询某人数 怎么 查询某个专业学生人数。 在线等 谢啦 ……
select count(*) from 学生表 where 专业 in ('计算机',英语',‘化...SQL语句 求各系、各班级的人数和平均年龄,表为Student,分组应该怎么分 ……
SQL语句 求各系、各班级的人数和平均年龄,表为Student,分组应该怎么分 ...怎样用SQL语...查询每个班使用的每种教材的数量的SQL语句怎么写 ……
select c.班级名称,b.教材名称,count(*) as 数量 from 学生使用教材表 a...
你可能感兴趣的内容? 上传我的文档
 下载
 收藏
该文档贡献者很忙,什么也没留下。
 下载此文档
正在努力加载中...
Oracle数据库课程设计报告学生成绩管理系统
下载积分:840
内容提示:Oracle数据库课程设计报告学生成绩管理系统
文档格式:DOC|
浏览次数:573|
上传日期: 22:46:00|
文档星级:
全文阅读已结束,如果下载本文需要使用
 840 积分
下载此文档
阅读此文档的用户还读了
Oracle数据库课程设计报告学生成绩管理系统
官方公共微信16447人阅读
数据库(4)
题目来源于http://blog.csdn.net/lifetragedy/article/details/9935699,由于原文题目中的数据在我自己建的DB里没有数据,所以解答中的条件可能是符合我DB的条件,而不是符合题目的条件。但解答应该符合题目的意思要求。但是文中的解答肯能会有错误,但都是经过我DB中实际跑过的。欢迎指出错误。
select * from t_student 学生表
select * from t_course 课程表
select * from t_sc 学生成绩表
select * from t_teacher 老师表
--http://blog.csdn.net/lifetragedy/article/details/9935699
--create table t_student(stuid number(10,2) primary key,name varchar2(100), age number(3,0), sex char(1));
--create table t_course(cid number(10,2) primary key, name varchar2(100), teacherid number(10, 2));
--alter table t_course
--add constraint tcourse_fk foreign key (teacherid) references t_teacher(tid);
--create table t_sc(stuid number(10, 2), cid number(10,2), score number(10,2));
--alter table t_sc
--add constraint t_sc_pk primary key (stuid, cid);
--alter table t_sc
--add constraint t_sc_stuid_fk foreign key (stuid) references t_student(stuid);
--alter table t_sc
--add constraint t_sc_cid_fk foreign key (cid) references t_course(cid);
--create table t_teacher(tid number(10,2) primary key, tname varchar2(100));
select * from t_
select * from t_
select * from t_
select * from t_
--查询“1”课程比“2”课程成绩高的所有学生的学号
select a.stuid
from (select * from t_sc s where s.cid = 1) a,
(select * from t_sc s where s.cid = 2) b
where a.stuid = b.stuid
and a.score & b.
select a.S#
from (select s#, score from SC where C# = '001') a,
(select s#, score from SC where C# = '002')
where a.score & b.score
and a.s# = b.s#;
--2、查询平均成绩大于80分的同学的学号和平均成绩;
select stuid, avg(score) from t_sc group by stuid having avg(score)&80;
--3、查询所有同学的学号、姓名、选课数、总成绩;
select s.stuid, s.name, c.xks, c.zcj
from t_student s left outer join
(select stuid, count(cid) xks, sum(score) zcj
group by stuid) c
on s.stuid = c.
select s.stuid, s.name, count(c.cid), sum(c.score)
from t_student s
left Outer join t_sc c
on s.stuid = c.stuid
group by s.stuid, s.
--4、查询姓“李”的老师的个数;
select count(tid) from t_teacher where tname like '李%';
--5、查询没学过“叶平”老师课的同学的学号、姓名;
select s.stuid,s.name from t_student s, t_course c, t_teacher t, t_sc sc where s.stuid=sc.stuid and c.cid=sc.cid and c.teacherid=t.tid and t.tname!='叶平';
select Student.S#, Student.Sname
from Student
where S# not in
(select distinct (SC.S#) from SC,
Teacher where SC.C# = Course.C#and Teacher.T# = Course.T# andTeacher.Tname = '叶平');
--6、查询学过“001”并且也学过编号“002”课程的同学的学号、姓名;
select s.stuid,s.name from t_student s, t_sc c where c.cid=1 and s.stuid=c.stuid and exists (select * from t_sc sc where sc.stuid=s.stuid and sc.cid=2);
-- select Student.S#,Student.Sname fromStudent,SC where Student.S#=SC.S# andSC.C#='001'and exists( Select * from SC as SC_2 where SC_2.S#=SC.S# and SC_2.C#='002');
--7、查询学过“叶平”老师所教的所有课的同学的学号、姓名;
select s.stuid,s.name from t_student s, t_sc sc where s.stuid = sc.stuid and sc.cid in(
select c.cid from t_teacher t, t_course c where t.tid=c.teacherid and t.tname='Mr.kay');
select S#, Sname
from Student
where S# in
(select S#
from SC, Course, Teacher
where SC.C# = Course.C# andTeacher.T# = Course.T#
and Teacher.Tname = '叶平'
group by S#
having count(SC.C#) = (select count(C#) from Course,
Teacher where Teacher.T# = Course.T# and Tname = '叶平'));
--8、查询课程编号“002”的成绩比课程编号“001”课程低的所有同学的学号、姓名;
Select S#, Sname
from (select Student.S#,
Student.Sname,
(select score
from SC SC_2
where SC_2.S# = Student.S#and SC_2.C# = '002') score2
from Student, SC
where Student.S# = SC.S# andC# = '001') S_2
where score2 &
--9、查询所有课程成绩小于60分的同学的学号、姓名;
select s.stuid, s.name from t_student s where s.stuid not in (select sc.stuid from t_student s, t_sc sc where sc.score&=60 and s.stuid=sc.stuid);
select s.stuid, s.name from t_student s where not exists (select * from t_sc sc where sc.stuid=s.stuid and sc.score&=60);
--10、查询没有学全所有课的同学的学号、姓名;
select s.stuid, s.name from t_student s,t_sc sc where s.stuid=sc.stuid group by s.stuid,s.name having count(sc.cid) != (select count(cid) from t_course);
select Student.S#, Student.Sname
from Student, SC whereStudent.S# = SC.S#
group by Student.S#, Student.Sname
having count(C#) & (select count(C#) from Course);
--11、查询至少有一门课与学号为“1001”的同学所学相同的同学的学号和姓名;
select distinct s.stuid,s.name from t_student s, t_sc sc where s.stuid=sc.stuid and s.stuid!=1 and
sc.cid in (select cid from t_sc where stuid=1)
--select s.stuid,s.name from t_Student s, t_SC sc where s.stuid=SC.Stuid and sc.cid in (select Cid from t_SC where stuid='1');
--13、把“t_SC”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩;
update t_sc sc1 set sc1.score =
(select avg(score) from t_sc group by cid having cid in (select cid from t_teacher t, t_course c where t.tid=c.teacherid and t.tname='Mr.mao') and cid=sc1.cid);
update t_sc sc_1
set sc_1.score =
(select avg(sc_2.score) from t_sc sc_2 where sc_2.cid = sc_1.cid)
from t_course,
where t_course.Cid = t_sc.cid and t_course.tid = t_teacher.tid
and t_teacher.tname = 'Mr.mao');
select * from t_sc sc, t_course c, t_teacher t where sc.cid=c.cid and c.teacherid=t.tid and t.tname='Mr.mao'
--14、查询和“1002”号的同学学习的课程完全相同的其他同学学号和姓名;
select * from t_sc where stuid in(
select stuid
group by stuid
having count(*) = (select count(*) from t_sc where stuid = 6)
and cid in (select cid from t_sc where stuid=6);
--15、删除学习“叶平”老师课的SC表记录
delete t_sc where cid in(
select cid from t_course c, t_teacher t where c.teacherid=t.tid and t.tname='Mr.mao');
--16、向SC表中插入一些记录,这些记录要求符合以下条件:没有上过编号“5”课程的同学学号、2号课的平均成绩;
insert into t_sc
select stuid, '5' cid, (select avg(score) from t_sc sc where sc.cid=2) score
from t_student s where not exists
(select * from t_sc sc where sc.cid=5 and sc.stuid=s.stuid);
--17、按平均成绩从高到低显示所有学生的“数据库”、“企业管理”、“英语”三门的课程成绩,按
--如下形式显示: 学生ID,,数据库,企业管理,英语,有效课程数,有效平均分
select t.stuid,
max(ame when 'Chinese' then t.score end) Chinese,
max(ame when 'Math' then t.score end) Math,
max(ame when 'English' then t.score end) English,
round(avg(t.score), 2) avgscore,
count(t.cid) kcs
from (select s.stuid, s.name stuname, sc.cid, sc.score, c.name cname
from t_student s, t_sc sc, t_course c
where s.stuid = sc.stuid
and sc.cid = c.cid
and c.name in ('Chinese', 'Math', 'English')) t
group by t.stuid
select sc.stuid,
(select score from t_sc where cid=1 and stuid=sc.stuid) Chinese,
(select score from t_sc where cid=2 and stuid=sc.stuid) Math,
(select score from t_sc where cid=3 and stuid=sc.stuid) English,
round(avg(sc.score),2) avgscore,
count(c.cid) kcs
from t_sc sc, t_course c where sc.cid=c.cid and c.name in ('Chinese', 'Math', 'English')
group by sc.stuid
--18、查询各科成绩最高和最低的分:以如下形式显示:课程ID,最高分,最低分
select cid, max(score) maxscore, min(score) minscore from t_sc group
SELECT L.Cid As 课程ID, L.score AS 最高分, R.score AS 最低分
WHERE L.Cid = R.Cid
and L.score = (SELECT MAX(IL.score)
IL, t_Student
WHERE L.Cid = IL.Cid
and IM.Stuid = IL.Stuid
GROUP BY IL.Cid)
AND R.Score =
(SELECT MIN(IR.score) FROM t_SC
IR WHERE R.Cid = IR.Cid GROUP BY IR.Cid);
--19、按各科平均成绩从低到高和及格率的百分数从高到低顺序
select sc.cid, (select name from t_course where cid=sc.cid) cname,
round(avg(sc.score),2) avgscore,
round((select count(*) from t_sc where cid = sc.cid and score&=70)/
(select count(*) from t_sc where cid = sc.cid)*100,2)||'%' jgl
from t_sc sc
group by sc.cid
order by avgscore,
SELECT t.C# AS 课程号,ame)AS 课程名,isnull(AVG(score),0) AS平均成绩
,100 * SUM(CASE WHEN
isnull(score,0)&=60 THEN 1 ELSE 0 END)/COUNT(*) AS 及格百分数
FROM SC T,Course
where t.C#=course.C#
GROUP BY t.C#
ORDER BY 100* SUM(CASE WHEN
isnull(score,0)&=60 THEN 1 ELSE 0 END)/COUNT(*) DESC
--20、查询如下课程平均成绩和及格率的百分数(用&1行&显示):
--企业管理(001),马克思(002),OO&UML (003),数据库(004)
select * from t_sc sc group by sc.cid
select sc.cid, (select name from t_course where cid=sc.cid) cname,
case sc.cid when 1 then round(avg(sc.score),2) end chinese_avgscore,
case sc.cid when 1 then
round((select count(*) from t_sc where cid = sc.cid and score&=70)/
(select count(*) from t_sc where cid = sc.cid)*100,2)||'%' end chinese_jgl
from t_sc sc
group by sc.cid
--21、查询不同老师所教不同课程平均分从高到低显示
select sc.cid,
round(avg(sc.score),2) avg_score,
from t_sc sc, t_course c, t_teacher t
where sc.cid=c.cid and t.tid=c.teacherid
group by sc.cid, c.name, t.tname
order by avg_
--22、查询如下语文成绩第 2 名到第 5 名的学生成绩单:
--[学生ID],[学生姓名],语文成绩, 排名
select * from (
select t.*, rownum tn from (
select s.stuid, s.name,
min(case c.name when 'Chinese' then sc.score end) chinese_score
from t_student s, t_sc sc, t_course c
where s.stuid = sc.stuid
and sc.cid = c.cid
group by s.stuid, s.name
order by chinese_score desc) t where rownum &=5) where tn&1
--23、统计列印各科成绩,各分数段人数:课程ID,课程名称,[100-85],[85-70],[70-60],[ &60]
select sc.cid, c.name,
(select count(*) from t_sc where cid=sc.cid and score&=85 and score&=100) a,
(select count(*) from t_sc where cid=sc.cid and score&=70 and score&85) b,
(select count(*) from t_sc where cid=sc.cid and score&=60 and score&70) c,
(select count(*) from t_sc where cid=sc.cid and score&60) d
from t_sc sc, t_course c
where sc.cid = c.cid
group by sc.cid, c.
SELECT SC.Cid as 课程ID, c.name as 课程名称
,SUM(CASE WHEN sc.score BETWEEN 85 AND 100 THEN 1 ELSE 0 END) AS a
,SUM(CASE WHEN sc.score BETWEEN 70 AND 85 THEN 1 ELSE 0 END) AS b
,SUM(CASE WHEN sc.score BETWEEN 60 AND 70 THEN 1 ELSE 0 END) AS c
,SUM(CASE WHEN sc.score & 60 THEN 1 ELSE 0 END) AS d
FROM t_SC sc,t_Course c
where SC.Cid=C.Cid
GROUP BY SC.Cid,c.
--24、查询学生平均成绩及其名次
select t.*, rownum rn from (
select s.stuid, s.name, avg(sc.score) avg_score from t_student s, t_sc sc where s.stuid=sc.stuid
group by s.stuid, s.name
order by avg_score desc)
select t.*, row_number() over(order by avg_score desc) pm from (
select s.stuid, s.name, avg(sc.score) avg_score
from t_student s, t_sc sc where s.stuid=sc.stuid
group by s.stuid, s.name
--25、查询各科成绩前三名的记录:(不考虑成绩并列情况)
select * from (
select sc.cid, c.name, sc.score, row_number() over(partition by sc.cid,c.name order by sc.score desc) pm
from t_sc sc, t_course c where sc.cid=c.cid ) where pm &=3;
SELECT t1.S# as 学生ID,t1.C# as 课程ID,Score as 分数
FROM SC t1
WHERE score IN (SELECT TOP 3 score
WHERE t1.C#= C#
ORDER BY score DESC
ORDER BY t1.C#;
--26、查询每门课程被选修的学生数
select cid, count(*) rs, (select name from t_course where cid=t_sc.cid) cname from t_
--27、查询出只选修了3门课程的全部学生的学号和姓名
select sc.stuid, s.name from t_sc sc, t_student s where sc.stuid = s.stuid group by sc.stuid,s.name having count(*) =3;
--28、查询男生、女生人数
select case when sex='1' then 'Man' else 'Woman' end sex, count(*) rs from t_
--29、查询姓“张”的学生名单
select * from t_student where name like 'w%';
--30、查询同名同性学生名单,并统计同名人数
select name, count(*) rs from t_student group by name having count(*)&1;
--31、1981年出生的学生名单(注:Student表中Sage列的类型是datetime)
select to_char(sysdate,'yyyy')
--32、查询每门课程的平均成绩,结果按平均成绩升序排列,平均成绩相同时,按课程号降序排列
select cid, round(avg(score),2) avg_score from t_sc group by cid order by avg_score,
--33、查询平均成绩大于85的所有学生的学号、姓名和平均成绩
select s.stuid, s.name, round(avg(sc.score), 2) avg_score from t_student s, t_sc sc where s.stuid=sc.stuid group by s.stuid, s.name having avg(sc.score)&80;
--34、查询课程名称为“数据库”,且分数低于60的学生姓名和分数
select s.stuid, s.name stuname, sc.score from t_student s, t_sc sc, t_course c where s.stuid=sc.stuid and sc.cid=c.cid and c.name='Computer' and sc.score&70;
--35、查询所有学生的选课情况
select s.stuid, s.name stuname, c.cid, c.name coursename from t_student s, t_sc sc, t_course c where s.stuid=sc.stuid and sc.cid=c.
--36、查询任何一门课程成绩在70分以上的姓名、课程名称和分数
select s.stuid, s.name stuname, c.cid, c.name coursename, sc.score from t_student s, t_sc sc, t_course c where s.stuid=sc.stuid and sc.cid=c.cid and sc.score&70;
--37、查询不及格的课程,并按课程号从大到小排列
select c.cid, c.name from t_sc sc, t_course c where sc.cid=c.cid group by c.cid,c.name,sc.score having sc.score&70 order by c.
--38、查询课程编号为003且课程成绩在80分以上的学生的学号和姓名;
select s.stuid, s.name, sc.score from t_student s,t_sc sc where s.stuid=sc.stuid and sc.cid=3 and sc.score&80;
--39、求选了课程的学生人数
select count(*) rs from (select stuid from t_sc group by stuid);
--40、查询选修“叶平”老师所授课程的学生中,成绩最高的学生姓名及其成绩
select s.stuid, s.name stuname, t.max_score from t_student s, t_sc sc,
(select c.cid, max(sc.score) max_score from t_sc sc, t_course c, t_teacher t where sc.cid=c.cid and c.teacherid=t.tid
and t.tname='Mr.mao' group by c.cid) t
where s.stuid=sc.stuid and sc.cid=t.cid and sc.score=t.max_
select S.name stuname, sc.score
from t_Student s, t_SC sc, t_Course C, t_Teacher t
where S.Stuid = SC.Stuid
and SC.Cid = C.Cid
and C.Teacherid = T.tid
and T.Tname = 'Mr.mao'
and SC.score = (select max(score) from t_SC where Cid = C.Cid);*/
--41、查询各个课程及相应的选修人数
select cid, count(*) rs from t_sc group
--42、查询不同课程成绩相同的学生的学号、课程号、学生成绩
select * from t_sc sc where exists (select * from t_sc where stuid!=sc.stuid and cid!=sc.cid and score=sc.score);
select distinct
A.Stuid,B.score from t_SC A
,t_SC B where A.Score=B.Score and A.Cid &&B.C
--43、查询每门功成绩最好的前两名
select * from (select stuid, cid ,score, row_number() over(partition by cid order by score desc) pm from t_sc) where pm&3;
SELECT t1.S# as 学生ID, t1.C# as 课程ID, Score as 分数
FROM SC t1
WHERE score IN
(SELECT TOP 2 score FROM SC WHERE t1.C# = C# ORDER BY score DESC)
ORDER BY t1.C#;
--44、统计每门课程的学生选修人数(超过10人的课程才统计)。要求输出课程号和选修人数,
--查询结果按人数降序排列,查询结果按人数降序排列,若人数相同,按课程号升序排列
select cid, count(*) rs from t_sc group by cid having count(*) & 5 order by rs desc,
--45、检索至少选修两门课程的学生学号
select stuid ,count(*) from t_sc group by stuid having count(*) & 2;
--46、查询全部学生都选修的课程的课程号和课程名
select c.cid, c.name from t_course c where exists (
select cid, count(*) rs from t_sc where cid=c.cid group by cid having count(*) = (select count(*) from t_student)
--47、查询没学过“叶平”老师讲授的任一门课程的学生姓名
select * from t_student where stuid not in(
select s.stuid from t_student s, t_sc sc where s.stuid=sc.stuid and
sc.cid in (select cid from t_course c, t_teacher t where c.teacherid=t.tid and t.tname='Mr.zhu'));
select * from t_Student s where s.stuid not in (select sc.stuid from t_Course c,t_Teacher t,t_SC sc where c.teacherid=T.Tid and SC.Cid=c.Cid and t.Tname='Mr.zhu');
--48、查询1门以上不及格课程的同学的学号及其平均成绩
select stuid, avg(score) avg_score from t_sc group by stuid having stuid in(
select stuid from t_sc where score&70 group by stuid having count(*) &1);
select S#,avg(isnull(score,0)) from SC where S# in (select S# from SC where score &60 group by S# having count(*)&1)group by S#;
--49、检索“5”课程分数小于60,按分数降序排列的同学学号
select stuid from t_sc where cid=5 and score&70
--50、删除“002”同学的“001”课程的成绩
delete from t_sc where stuid=2 and cid=1;
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:43055次
排名:千里之外
原创:15篇
(1)(5)(4)(2)(1)(1)(3)扫二维码下载作业帮
拍照搜题,秒出答案,一键查看所有搜题记录
下载作业帮安装包
扫二维码下载作业帮
拍照搜题,秒出答案,一键查看所有搜题记录
从学生选课数据库中查询选修“数据库原理”课并且成绩在90分以上的学生名单,请写出SQL语句.22.假设学生选课数据库关系模式如下:Student (SNo, SName,SSex, SClass);学生表:学号,学生姓名,性别,班级Course (CNo, CName) ;
课程表:课程编号,课程名称StudentCourse SC (SNo,CNo, Score)
成绩表:学号,课程编号,成绩b 分班级统计出至少有一门不及格的人数.请写出SQL语句. (8分)数据格式:班级,不及格人数
提示:可以利用子查询
扫二维码下载作业帮
拍照搜题,秒出答案,一键查看所有搜题记录
select sname from studentwhere sno in(select a.sno from studentcourse a join course boame='数据库原理' and a.score>90)select a.sclass as 班级,count(*) as 不及格人数 fromstudent a join studentcourse bon a.sno=b.snowhere b.score
为您推荐:
其他类似问题
扫描下载二维码

我要回帖

更多关于 帕萨特 u盘部分歌曲 的文章

 

随机推荐