Database Benchmarking exercise End (32~45)

Source: Internet
Author: User

--32, query all "female" teacher and "female" classmate's name, Sex and birthday.SelectSname, Ssex, Sbirthday fromStudentwhereSsex= 'female' Union SelectTname, Tsex,tbirthday fromTeacherwhereTsex= 'female';--33. Check the scores of students who have a lower average score than the course. SelectC.cno,c.degree fromscore CwhereC.degree<(Select avg(S.degree) fromScore SwhereS.cno=C.cnoGroup  bys.cno);--34. Check the Tname and depart of all classroom teachers.SelectT.tname, T.depart fromTeacher T, course CwhereT.tno=C.tno;--35, check the Tname and depart of all teachers who have not lectured.Select distinctT.tname, T.depart fromTeacher T, course CwhereT.tno not inch(SelectTno fromcourse);--36. Check the class number of at least 2 boys. Select *  from(SelectS.sclass,Count(S.sclass) C fromStudent SwhereS.ssex= 'male' Group  byS.sclass)whereC>=2 ; --37, inquires the student table the surname "the king" the classmate record. Select *  fromStudent SwhereS.sname not  like 'Wang%'; --38. Check the name and age of each student in the student table. SelectS.sname,to_char (Sysdate,'yyyy')-To_char (S.sbirthday,'yyyy') fromstudent S;--39. Query the maximum and minimum sbirthday date values in the student table. Select min(s.sbirthday) Max birthday,Max(s.sbirthday) Minimum birthday fromstudent S;--40. Check all records in the student table in order of class number and age from large to small. Select *  fromStudent SOrder  byS.sclassdesc, S.sbirthday;--41. Query "male" teachers and their courses. SelectT.tname,c.cname fromTeacher T,course CwhereT.tno=C.tno andT.tsex= 'male';--42. Check the SNO, CNO and degree columns of the students with the highest score. SelectS.sname,c.cname,r.degree fromStudent S, course C,score RwhereR.degree=(Select Max(degree) fromscore) andS.sno=R.sno andC.cno=R.cno;--43, inquiries and "Li June" with the gender of all students sname.SelectT.sname fromStudent TwhereT.ssex=(SelectS.ssex fromStudent SwhereS.sname= 'Li June');--44, inquiries and "Li June" with the same sex and classmates sname.SelectT.sname fromStudent TwhereT.ssex=(SelectS.ssex fromStudent SwhereS.sname= 'Li June') andT.sclass=(SelectS.sclass fromStudent SwhereS.sname= 'Li June');--45. Check the scores of all the "male" students who have enrolled in the "Introduction to Computer" course. SelectT.sname,t.ssex,s.degree fromScore S,course C,student TwhereS.cno=C.cno andS.sno=T.sno andT.ssex= 'male'  andC.cname= 'Introduction to Computers';

Database Benchmarking exercise End (32~45)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.