对于教学数据库的三个基本表: Stdent(SNO,SNAME,AGE,SEX) SC(SNO,CNO,GRADE) Course(CNO,CNAME,TEACHER) 试用SQL的查询语句表达下列查询: 1)检索学号为S3的学生所学课程的课程号与成绩。(5分) 2)检索年龄大于20岁的女学生的姓名和性别。(5分) 3)检索“数据库”课程的课程号。(10分) 4)检索王敏同学没有选修的课程的课程号。(10分) 5)统计每门课程的学生选修人数(超过15人的课程才统计)。要求显示课程号,课程名和人数,查询结果按人数降序排列,若人数相同,按课程号升序排列。(10分) 6)求刘老师所授课程的每门课程的成绩的最高分和最低分。(10分)
时间: 2024-04-04 19:32:02 浏览: 122
学生信息管理系统_数据库课程设计报告之欧阳文创编.docx
1)SELECT CNO, GRADE FROM SC WHERE SNO = 'S3';
2)SELECT SNAME, SEX FROM Student WHERE AGE > 20 AND SEX = '女';
3)SELECT CNO FROM Course WHERE CNAME = '数据库';
4)SELECT CNO FROM Course WHERE CNO NOT IN (SELECT CNO FROM SC WHERE SNO = (SELECT SNO FROM Student WHERE SNAME = '王敏'));
5)SELECT C.CNO, C.CNAME, COUNT(*) AS NUM FROM Course AS C JOIN SC ON C.CNO = SC.CNO GROUP BY C.CNO, C.CNAME HAVING NUM > 15 ORDER BY NUM DESC, C.CNO ASC;
6)SELECT CNO, MAX(GRADE) AS MAX_GRADE, MIN(GRADE) AS MIN_GRADE FROM SC WHERE CNO IN (SELECT CNO FROM Course WHERE TEACHER = '刘老师') GROUP BY CNO;
阅读全文