在学籍管理中,设有4个表,关系模式分别为:
ST[JDENT(SNO,SNAME,SEX,BIRTFtDAY,CLASS)
TEAC腿R(1FNO,TNAME.SEX.BIRTHDAY,PROFESSION,DEPARTMENT)
CO[JRSE(CNO,CNAME,TNO)
SCORE(SNO,CNO,DEGREE)
说明:学生关系模式中:SNO:学号;SNAME:姓名;SEX:性别;BIRTHDAY:出生口期;CI.ASS:班级:教师关系模式巾:TNO:教师号;TNAME:姓名;SEX:性别;BIRTHDAY:I叶{生口期;PRO—FESSION:职称;DEPARTMENT:所在系;
课程关系模式中:CNO:课程号;CNAME:课程名;TNO:任课教师号;
成绩关系模式中:SNO:学号;CNO:课程号;DEGREE:分数。
请用SQI。查询语句实现下列操作:
1)显示教师所有的单位,即不重复的DEPARTMENT列。
2)显示STIJDENT表中"95031.'班或性别为“女”的同学记求。
3)以CNO升序,DEGREE降序显示SCORE表的所有记录。
4)显示"9503l”班的学生人数。
5)显示SCORE表中至少有5名学生选修的并I:2 3 H:头的课程号的平均分。
6)显示最低分大于70,最高分小于90的SNO列。
7)显示选修“3一105”课程的成绩高于“109”号同学成绩的所有同学的记录。
8)显示SCORE表中选学多门课程的同学中分数为非最高分成绩的记录。
9)列出学号为“108'’的同学同年出生的所有学生的SNO、SNAME和BIRTHDAY。
10)显示“张三”教师任课的学生成绩。
答案说明:本题目答案来自网络整理或转载,最终答案请以官网为准。
答 案:l)SELECT DISTICT DEPARTMENT FROM TEACHER;2)SELECT* FROM STUDENT WHERE CLASS=‘9503l’OR SEX=‘女’;3)SELECT* FROM SCORE ORDER BY CNOASC DEGREE DESC;4)SELECT COtJNT(*) FROM STUDENT WHERE CLASS=‘9503l’:5)SELECT CNO.AVG(DEGREE) FROM SCORE WHERE CNO like‘3%’ GROUP BY CNO HAV-ING COUNT(*)>5;6)SELECT SNO FROM SCORE GROUP BY SNOMIN(DEGREE)>70 AND MAX(DEGREE)<90;7)SELECT X.CNOX.SNO.X.DEGREE FROM SCORE X.SCORE Y WHERE X.CNO=‘3—105’AND X.CNO=Y.CNO AND Y.SNO=‘109’AND X.DEGREE>Y.DEGR:EE:8)SELECT A.SNOA.DEGREE.A.CNO FROM SCORE A.SCORE B WHERE A.SNO=B.SNO AND A.DEGREE<B.DEGREE:9)SELECT SNOSNAME.BIRTHDAY FROM STUDEN'I、WHERE YEAR(BIRTHDAY)= (SELECT YEAR(BIRTHDAY) FROM STUDENT WHERE SNO=“108’);10)SELECT CNO. SNO.DEGREE FROM SCORE WHERE CNO= (SELECTX.CNO FROM COURSE X.TEACHER Y WHERE X.TNO=Y.TNO AND Y.TNAME=‘张三’)。
l)SELECT DISTICT DEPARTMENT FROM TEACHER;2)SELECT* FROM STUDENT WHERE CLASS=‘9503l’OR SEX=‘女’;3)SELECT* FROM SCORE ORDER BY CNOASC DEGREE DESC;4)SELECT COtJNT(*) FROM STUDENT WHERE CLASS=‘9503l’:5)SELECT CNO.AVG(DEGREE) FROM SCORE WHERE CNO like‘3%’ GROUP BY CNO HAV-ING COUNT(*)>5;6)SELECT SNO FROM SCORE GROUP BY SNOMIN(DEGREE)>70 AND MAX(DEGREE)<90;7)SELECT X.CNO,X.SNO.X.DEGREE FROM SCORE X.SCORE Y WHERE X.CNO=‘3—105’AND X.CNO=Y.CNO AND Y.SNO=‘109’AND X.DEGREE>Y.DEGR:EE:8)SELECT A.SNO,A.DEGREE.A.CNO FROM SCORE A.SCORE B WHERE A.SNO=B.SNO AND A.DEGREE<B.DEGREE:9)SELECT SNO,SNAME.BIRTHDAY FROM STUDEN'I、WHERE YEAR(BIRTHDAY)= (SELECT YEAR(BIRTHDAY) FROM STUDENT WHERE SNO=“108’);10)SELECT CNO. SNO.DEGREE FROM SCORE WHERE CNO= (SELECTX.CNO FROM COURSE X.TEACHER Y WHERE X.TNO=Y.TNO AND Y.TNAME=‘张三’)。 解析:主要考查了SQL的数据查询功能、数据定义功能和数据操纵功能。这类问题主要是考查对sELECT FROM WHERE语句的掌握。