1显示系部编号为03的系部名称
Select departname
From department
Where departno=03
2.查询系部名称中含有'工程'两个字的系部的名称。
Select departname
From department
Where departname like%工程%
3查询共有多少个系部。
Select count(departno)
From department
4查询'01'年级共有多少个班级。
Select count(*)
From class
Where classname like01%
5查询在'周二晚'上课的课程名称和老师。
select couname as '课程名称',teacher as'教师'
from course
where schooltime='周二晚'
6查询姓 张,陈,黄 同学的基本信息,要求按照姓名降序排序。
select *
from Student,StuCou,Course
where student.StuNo=stucou.stuno and
uno and
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 department.departno=course.departno
Group by departname
9.按课程统计平均报名人数,要求给出课程的详细信息和课程平均报名人数。
SELECT Kind '课程类别',AVG(WillNum)'每类平均报名人数'
FROM Course
group BY Kind
haveing avg(willnum)
10.按课程统计平均报名人数,要求给出课程名称、平均报名人数,按照平均报名人数降序排序。
SELECT Kind '课程类别',AVG(WillNum)'每类平均报名人数'
FROM Course,Department
where Course.DepartNo=department.DepartNo
group BY Kind
11.统计各系的班级数,要求显示系部名称、班级数量。
Select departname,count(classno)
From department,class
Where department.departno=class.departno
Group by departname
12.查询“甘蕾”同学选修的课程名、学分、上课时间和课程门数,按学分排序查询结果。
Select couname,credit,schooltime
From student,course,stucou
Where student.stuno=stucou.stuno uno and Stuname=’甘蕾’
Order by credit desc
13.按班级分组显示学生选课的信息,包括班级名、学号、姓名、课程、学分、上课时间。统计各班同学选修课程的总数。
select classname,stuname,student.StuNO,CouName,credit,schooltime
from class,student,course,StuCou,Department 
where Student.StuNo=StuCou.StuNo
order by ClassName   
14.查询统计各系开设选修课程的情况,内容包括系名、课程编号、课程名称、学分、教师、上课时间、限选人数,并统计各系开课门数。
sql统计每个系的学生人数select uno,couname,credit,teacher,schooltime,limitnum
from department,course
where department.departno=course.departno
order by departname
compute count(couname) by departname
15. 显示“00电子商务”班的选修报名结果,要求有姓名、课程名称、志愿号,并按姓名、志愿号排序。
Select stuname,couname,willorder
From stucou,class,course,student
uno and student.classno=class.classno and stucou.stuno=student.stuno and classname=00电子商务’
Order by stuname,willorder

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。