全文预览

一个题目涉及到的50个Sql语句

上传者:火锅鸡 |  格式:doc  |  页数:7 |  大小:68KB

文档介绍
和选修人数,查询结果按人数降序排列,查询结果按人数降序排列,若人数相同,按课程号升序排列Р select C# as 课程号,count(*) as 人数Р from sc Р group by C#Р order by count(*) desc,c# Р45、检索至少选修两门课程的学生学号Р select S# Р from sc Р group by s#Р having count(*) > = 2Р46、查询全部学生都选修的课程的课程号和课程名Р select C#,Cname Р from Course Р where C# in (select c# from sc group by c#) Р47、查询没学过“叶平”老师讲授的任一门课程的学生姓名Р select Sname from Student where S# not in (select S# from Course,Teacher,SC where Course.T#=Teacher.T# and SC.C#=course.C# and Tname='叶平');Р48、查询两门以上不及格课程的同学的学号及其平均成绩Р select S#,avg(isnull(score,0)) from SC where S# in (select S# from SC where score <60 group by S# having count(*)>2)group by S#;Р49、检索“004”课程分数小于60,按分数降序排列的同学学号Р select S# from SC where C#='004'and score <60 order by score desc;Р50、删除“002”同学的“001”课程的成绩Рdelete from Sc where S#='001'and C#='001';

收藏

分享

举报
下载此文档