实验二oracle单表查询

实验类型:验证性

实验学时:4学时

一、实验目的

学习sql连接查询,掌握单表查询方法。

二、实验内容

使用select语句完成以下操作:

(1)查询“cs”系,姓“刘”的学生学号和姓名;

(2)查询先行课(cpno)为空的课程名称;

(3)查询选修了“1”号课程的学生学号,按学号由小到大排列;

(4)统计选修了课程的学生人数;

(5)查询选修了“1”号课程,并且成绩90分以上的学生人数;

(6)统计各门课程的选修人数;

(7)统计每个学生的选课门数;

(8)查询选修的课程超过二门的学生学号及选课门数;

(9)查询每个系男女生的人数、平均年龄;

三、实验结果参考

(1)

select sno,sname from student where sdept='cs' and sname like'刘%';

(2)

selectcname from course where cpno is null;

(3)

selectsno from sc where cno='1' order by sno;

(4)

select count(distinct sno) from sc ;

(5)

select count(sno) from sc where cno='1' and grade>=90;

(6)

selectcno,count(sno) from sc group by cno;

(7)



selectsno,count(cno) from sc group by sno;

(8)

selectsno,count(cno) from sc group by sno having count(cno)>2;

(9)

selectsdept,ssex,count(sno),avg(sage)  from student group by sdept,ssex;

你可能感兴趣的:(orcale)