发布时间 : 星期三 文章数据库基础练习题解答更新完毕开始阅读75f14c21dd36a32d7375814a
--1、显示系部编号为“”的系部名称! select departname as '系部名称' from department where departno='03'
--2、查询系部名称中含有“工程”两个字的系的全名。 select departname '系部名称' from department
where departname like'%工程%'
--3、查询共有多少个系部。 select departname '系部名称' from department
compute count(departname)
--4、查询“01”年级共有多少个班级。 select count(classname) as '班级总数' from class
where classname like'01%'
--5、查询在“周二晚”上课的课程名称和教师。 select couname as '课程名称',teacher as '教师' from course
where schooltime='周二晚'
--6、查询姓“张”、“陈”、“黄”同学的的基本信息,要求按照姓名降序排序。 select * from student
Where stuname like'张%' or stuname like'陈%' or stuname like'黄%'
order by stuname desc
--7、按系部统计课程的平均报名人数,要求显示系部编号、平均报名人数。
select departno '系部编号',avg(willnum) '平均报名人数'
from course group by departno
--8、按系部统计课程的平均报名人数,要求显示系部名称、平均报名人数。
select departname '系部名称',avg(willnum) '平均报名人数'
from course,department
where course.departno=department.departno group by departname
--9、统计各系的班级数,要求显示系部编号、系部名称、班级数量。
select class.departno '系部编号',departname '系部名称',count(classname) '班级数量' from class,department
where class.departno=department.departno group by class.departno,departname
--10、查询“甘蕾”同学选修的课程名、学分、上课时间、志愿号,按志愿号排序查询结果。
select couname '课程名',credit '学分',schooltime '上课时间',willorder '志愿号' from course,stucou,student
where course.couno=stucou.couno and student.stuno=stucou.stuno and stuname='甘蕾' order by willorder
--11、显示“电子商务班”班的选修报名结果。要求有学号、姓名、课程编号、
--课程名称、志愿号,并按学号、志愿号排序。
select student.stuno '学号',stuname '姓名',stucou.couno '课程编号',couname '课程名称',willorder '志愿号'
from student,course,stucou,class where course.couno=stucou.couno and student.stuno=stucou.stuno and class.classno=student.classno and classname='00电子商务'