|
第一题- select T1.stuID,stuName,score from ([tblscore$] T1 left join [tblstudent$] T2 on T1.Stuid= T2.stuid) where T1.courseID in (Select courseID from [tblcourse$] where coursename="数据库") order by score desc
复制代码 第二题- select T2.CourseID,format(成绩,"0.00") as 平均成绩,format(countjg/countall,"0%") as 及格率 from ((select courseid,count(courseid) as countjg from [tblscore$] where score>60 group by courseid)T1 right join (select courseid,count(courseid) as countall,avg(score) as 成绩 from [tblscore$] group by courseid )T2 on T1.Courseid= T2.Courseid) order by 成绩
复制代码 第三题:主题在网络上百度到了语句思路。没懂。。囧- Select *,(Select count(*)+1 from (select stuid as 学号,format(avg(score),"0.00") as 平均成绩 from [tblscore$] group by stuid) T2 where 平均成绩>T1.平均成绩 ) as 名 from (select stuid as 学号,format(avg(score),"0.00") as 平均成绩 from [tblscore$] group by stuid) T1
复制代码 第四题:又臭又长。。。。何必呢。。。。- select * from [tblscore$] where courseid & score in ( select courseid & max(score) as score from (select * from [tblscore$] where CourseID & StuID & Score not in (select CourseID & StuID & Score from (select * from [tblscore$] where courseid & score in (Select courseid & max(score) as score from (select * from [tblscore$] where CourseID & StuID & Score not in (select CourseID & StuID & Score from [tblscore$] where CourseID & Score in (select CourseID & Score from (select CourseID,Max(Score) as Score from [tblscore$] group by CourseID)) order by courseid) and courseid in (select courseid from [tblscore$] where CourseID & Score in (select CourseID & Score from (select CourseID,Max(Score) as Score from [tblscore$] group by CourseID)) group by courseid having count(courseid)<3)) group by courseid) union select * from [tblscore$] where CourseID & Score in (select CourseID & Score from (select CourseID,Max(Score) as Score from [tblscore$] group by CourseID)))) and courseID in (Select courseID from (select * from [tblscore$] where courseid & score in (Select courseid & max(score) as score from (select * from [tblscore$] where CourseID & StuID & Score not in (select CourseID & StuID & Score from [tblscore$] where CourseID & Score in (select CourseID & Score from (select CourseID,Max(Score) as Score from [tblscore$] group by CourseID)) order by courseid) and courseid in (select courseid from [tblscore$] where CourseID & Score in (select CourseID & Score from (select CourseID,Max(Score) as Score from [tblscore$] group by CourseID)) group by courseid having count(courseid)<3)) group by courseid) union select * from [tblscore$] where CourseID & Score in (select CourseID & Score from (select CourseID,Max(Score) as Score from [tblscore$] group by CourseID))) group by courseid having count(courseID)<3)) group by courseid) union select * from [tblscore$] where courseid & score in (Select courseid & max(score) as score from (select * from [tblscore$] where CourseID & StuID & Score not in (select CourseID & StuID & Score from [tblscore$] where CourseID & Score in (select CourseID & Score from (select CourseID,Max(Score) as Score from [tblscore$] group by CourseID)) order by courseid) and courseid in (select courseid from [tblscore$] where CourseID & Score in (select CourseID & Score from (select CourseID,Max(Score) as Score from [tblscore$] group by CourseID)) group by courseid having count(courseid)<3)) group by courseid) union select * from [tblscore$] where CourseID & Score in (select CourseID & Score from (select CourseID,Max(Score) as Score from [tblscore$] group by CourseID)) order by courseid
复制代码 第五题- select * from (select T1.StuId,stuname,avg(score) as score_avg from ([tblscore$] T1 left join [tblstudent$] T2 on T1.Stuid= T2.stuid) group by T1.stuid,stuname)where score_avg > 85
复制代码 哎。彻底被打败了。。。这个练习就这样了
|
|