资源描述:
《数据库原理与应用(何玉洁-梁琦编著)第五章课后习题答案.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、1.SELECT*FROMSC2.SELECTSname,SageFROMStudentWHERE(Sdept='计算机系')3.SELECTSno,Cno,GradeFROMSCWHERE(GradeBETWEEN70AND80)4.SELECTSname,SageFROMStudentWHERE(Sdept='计算机系')AND(Ssex='男')5.SELECTMAX(Grade)ASc01最高成绩FROMSCWHERE(Cno='c01')6.SELECTMAX(Sage)AS最大年龄,MIN(Sag
2、e)AS最小年龄FROMStudentWHERE(Sdept='计算机系')7.SELECTSdept,COUNT(*)AS学生人数FROMStudentGROUPBYSdept8.SELECTCno,COUNT(*)AS选课人数,MAX(Grade)AS最高分FROMSCGROUPBYCno9.SELECTSno,COUNT(*)AS选课门数,SUM(Grade)AS总成绩FROMSCGROUPBYSnoORDERBYCOUNT(*)10.SELECTSno,SUM(Grade)AS总成绩FROMSCGRO
3、UPBYSnoHAVING(SUM(Grade)>200)11.SELECTSname,SdeptFROMStudentWHERE(SnoIN(SELECTsnoFROMscWHEREcno='c02'))12.SELECTs.Sname,SC.Cno,SC.GradeFROMStudentsINNERJOINSCONs.Sno=SC.SnoWHERE(SC.Grade>80)ORDERBYSC.GradeDESC13.SELECTSno,Sname,SdeptFROMStudentWHERE(NOTEXIS
4、TS(SELECT*FROMscWHEREsc.sno=student.sno))或者SELECTSno,Sname,SdeptFROMStudentWHERE(SnoNOTIN(SELECTsnoFROMsc))14.SELECTCname,SemesterFROMCourseWHERE(Semester=(SELECTsemesterFROMcourseWHEREcname='VB'))或者SELECTc2.Cname,c2.SemesterFROMCoursec1INNERJOINCoursec2ONc
5、1.Semester=c2.SemesterWHERE(c1.Cname='VB')15.SELECTs2.Sname,s2.Sdept,s2.SageFROMStudents1INNERJOINStudents2ONs1.Sage=s2.SageWHERE(s1.Sname='李勇')AND(s2.Sname<>'李勇')或者SELECTSname,Sdept,SageFROMStudentWHERE(Sage=(SELECTsageFROMstudentWHEREsname='李勇'))AND(Sname
6、<>'李勇')16.SELECTTOP2WITHTIESSname,SageFROMStudentWHERE(Sdept='计算机系')ORDERBYSage17.SELECTStudent.Sname,Student.Sdept,SC.GradeFROMStudentINNERJOINSCONStudent.Sno=SC.SnoWHERE(SC.GradeIN(SELECTTOP2WITHtiesgradeFROMscWHEREcno=(SELECTcnoFROMcourseWHEREcname='VB')
7、ORDERBYgradeDESC))或者SELECTTOP2WITHTIESStudent.Sname,Student.Sdept,SC.GradeFROMStudentINNERJOINSCONStudent.Sno=SC.SnoINNERJOINCourseONSC.Cno=Course.CnoWHERE(Course.Cname='VB')ORDERBYSC.GradeDESC18.SELECTTOP2WITHTIESSno,COUNT(*)AS选课门数FROMSCGROUPBYSnoORDERBYCO
8、UNT(*)DESC19.SELECTTOP1WITHTIESSdept,COUNT(*)AS学生人数FROMStudentGROUPBYSdeptORDERBYCOUNT(*)DESC20.(1)SELECTSname,SdeptFROMStudentWHERE(SnoIN(SELECTsnoFROMscWHEREcno='c01'))(2)SELECTStudent.Sno,Student.Sn