Database Queries 4

Source: Internet
Author: User

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

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.