Orcle Database review: Two

Source: Internet
Author: User

First, the topic

1. Find out the names of all students who have scored below 80

SelectSname fromStudentwhereSidinch(SelectSid fromMarkGroup  bySid having Max(Cmark)< the)SelectSname fromStudentwhereSidinch(SelectSid fromMarkwhereSid not inch(SelectSid fromMarkwhereCmark>= the))

2. Find the names of students who are exactly the same as the Zhang San students ' chosen course

STEP1:SelectSid fromStudentwhereSname='Zhang San'Step2:SelectCid fromMarkwhereSid=(STEP1) Step3:SelectSid fromMarkwhereCid not inch(STEP2) Step4:SelectSid fromMarkwhereSid not inch(STEP3)Group  bySid having Count(*)=(Select Count(*) fromMarkwhereSid=(STEP1))

3. Show Zhang San's math and English scores, require display of names, math scores, English scores

Selectsname, (SelectCmark fromMarkwhereSid=(SelectSid fromStudentwhereSname='Zhang San')  andCID=(SelectCid fromCoursewhereCName='Mathematics') ) Mathematical results, (SelectCmark fromMarkwhereSid=(SelectSid fromStudentwhereSname='Zhang San')  andCID=(SelectCid fromCoursewhereCName='English')) English score fromStuden
Students who have at least 10002 elective courses
Mleftjoin   on s.sid =where Cmark <  -

5. Find out the names of all students who have failed courses

Select  from  Left Join  on S.sid=where cmark<

6. Student number of at least 10002 elective courses

SelectSid fromMark SC1where  not exists(Select *  fromMark SC2whereSid=10002  and  not exists(Select * fromMarkwhereSid=Sc1.sid andCid=sc2.cid)) andSid!=10002 Group  bySid

7. The names of students who have at least enrolled in all courses Zhang San elective

SelectSid fromMark SC1where  not exists(Select *  fromMark SC2whereSid=(SelectSid fromStudentwhereSname='Zhang San') and  not exists(Select * fromMarkwhereSid=Sc1.sid andCid=sc2.cid)) andSid!=10002 Group  bySid

Orcle Database review: Two

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.