1 --Check the Tname and depart of all instructors.2 SelectT.tname teacher, c.cname course Name fromTeacher T,course CwhereT.tno=C.tno;3 --Check the student table of the students who do not have the surname "Wang" record. 4 Select * fromStudent TwhereT.sname not like 'Wang%';5 --Query the name and age of each student in the student table. 6 SelectSt.sname,extract ( Year fromSysdate)-Extract Year fromSt.sbirthday) asAge fromStudent St;7 --queries the maximum and minimum sbirthday date values in the student table. 8 Select Max(Extract ( Day fromSt.sbirthday)) Max,min(Extract ( Day fromst.sbirthday)) min. fromStudent St;9 --query "Male" teachers and their courses. Ten SelectT.tname Name, c.cname course fromTeacher T,course CwhereT.tno=C.tno; One --Query the SNO, CNO and degree columns of the highest score. A Select * fromScore SCwhereSc.degree=(Select Max(degree) fromscore); - --inquiries and "Li June" with the sex of all the classmates sname. - SelectSt.sname fromStudent StwhereSt.ssex=(SelectS.ssex fromStudent SwhereS.sname='Li June'); the --enquiries and "Li June" with the same sex and classmates sname. - SelectSt.sname fromStudent StwhereSt.ssex=(SelectSt1.ssex fromStudent St1whereSt1.sname='Li June') - andSt.class=(SelectSt1.class fromStudent St1whereSt1.sname= 'Li June'); - --check out the scores of all the "male" students who took the "Introduction to Computer" course. + Select * fromScore SCwhereSc.cno=(SelectC.cno fromCourse CwhereC.cname='Introduction to Computers') - andSc.snoinch(SelectSt.sno fromStudent StwhereSt.ssex= 'male'); + --query all records in the student table in order of class number and age from large to small. A Select * fromStudent StOrder bySt.classdesc, Extract ( Year fromSysdate)-Extract Year fromSt.sbirthday)desc; at --Check the Tname and depart of all teachers who have not lectured. - SelectT.tname,t.depart fromTeacher TwhereT.tno=( - SelectC.tno fromCourse CwhereC.cno not inch(SelectSc.cno fromScore SCGroup bysc.cno)); - --check the class number of at least 2 men. - SelectSt.class fromStudent StGroup bySt.class having Count(St.ssex)>=2; - --The Sno, Sname and Sbirthday of all the students who were born in the same year were queried and studied for the student number 108. in SelectSt.sno,st.sname,st.sbirthday fromStudent StwhereSt.sno<>'108' andExtract Year fromSt.sbirthday)= -(SelectExtract Year fromSt2.sbirthday) fromStudent St2whereSt2.sno='108') ;
Database Queries 4