欢迎来到天天文库
浏览记录
ID:62637571
大小:29.70 KB
页数:10页
时间:2021-05-15
《数据库完整查询作业.docx》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、设教学数据库Education有三个关系:学生关系S(SNO,SNAME,AGE,SEX,SDEPT);学习关系SC(SNO,CNO,GRADE);课程关系C(CNO,CNAME,CDEPT,TNAME)查询问题:1查所有年龄在20岁以下的学生姓名及年龄。1selectisnj,2fromstudent3where三zig亡120;,-_Jstudent(2x3)'snosage201U512210201215123闵201J1S12S192:查考试成绩有不及格的学生的学号1select2fromsc3whereJJSC41〕;/sno20121^1223:查所年龄
2、在20至23岁之间的学生姓名、系别及年龄。1selectsnaT亡」乞勺亡呂亡2fromstudent3wheresagebetween28and23;/.1student(3«1)>snamessexsagebyongm204:查计算机系、数学系、信息系的学生姓名、性别。1selectsnar^j2fromstLident3wheresdeptin(''ci*1,3uisn)10/10,■'lJstudent(2*4}少snamessexiiyongliudienwwangminm岀anMm5:查既不是计算机系、数学系、又不是信息系的学生姓名、性别1selec
3、tsn3-e,is2fromstudent3wheresdeptnotinsname丿snossexliuchen201215122w7:查姓“上官”且全名为3个汉字的学生姓名1selectsnaire2fromstudent3where■:已”生likeJ,,sh3nguanJstudent
4、(lxl)S-=—「丄—i!1———■#snameshanguanyun&查所有不姓“张”的学生的姓名。10/101select2fromstudent3wheresnamenotlikezhang^";/LJstudent(Ix-^'於snarneliuchenliyongshanguanyunwangmin9:查DB_Design课程的课程号。1selectcnc2frofliecuse3where:nare1ike"db-design1';『雷OMBe(1*3)eno10:查缺考的学生的学号和课程号1selectsric,cna2frewnSC3whereg.
5、-adeisnull;sc(2xl)>sno-Peno201215123111:查年龄为空值的学生的学号和姓名。1selectsnojjnarre2fromstudent3whereisnull;■.Jstudent(2x1)5noZsname201215124shangjanyu仃12:查计算机系20岁以下的学生的学号和姓名。1selectsiDjjnars2fromstudent3wheresdept=Mcs"'and^age<2©;._istudent(2x1)少snameliuchen10/1013:查计算机系、数学系、信息系的学生姓名、性别。1sele
6、ct2fromstudent3wheresdeptin("csN7rT=","is'1);Lstudent(2x4)>snamessexliyonqmliudienw妆
7、呂ngmirimzhanglimi14:查询选修了C3课程的学生的学号和成绩,其结果按分数的降序排列。1selectsn3tgrac;e2fromsc3wherecno='3"4orderbydesc;2012151228015:查询全体学生的情况,查询结果按所在系升序排列,对同一系中的学生按年龄降序排列。1select*2fromLucent3orderbysc即:』v次desc;JLjstijd
8、ent(5K5)'i.-■■sno*snanessexsdept201215121tn20CS201215122iwhenw19cs201215124mh日「guar出nmdb201215125zhangflm19is201215123wangirji13帕16:查询学生总人数。1selectcounti*)2fromstudent;3结果#1(txi)10/10a)unt(*)517:查询选修了课程的学生人数。1selectcount(distinctsno^2frornsz;结果*1(lxl)count(distiiKtsno)18:计算选修了C1课程的学生
此文档下载收益归作者所有