A SQL Written exam question: Use standard SQL nested statements to query the names and units of the students taking all courses

Source: Internet
Author: User

S (Sno,sname,sdd,sage)

Sno,sname,sdd,sage

Each representative of the school number, learning

Member's name, affiliation, student's age

C (Cno,cname)

Cno,cname

Represent the course number, the course name, respectively

SC (Sno,cno,score)

Sno,cno,score

Representing the school number,

of the Elective

Course number, learning score

The data for the three tables are as follows:

Problem:

Use standard SQL nested statements to query the name and affiliation of the student taking all courses

Write your own sql:

SELECT SNO,SDD from S WHERE SNO in
(
Select Sno from
(
SELECT Sno,count (SC.CNO) as COUNTC from SC right JOIN C on SC. Cno=c.cno
GROUP by SNO have COUNT (sc.cno) = (select COUNT (distinct c.cno) from c)
) A
);

A SQL Written exam question: Use standard SQL nested statements to query the names and units of the students taking all courses

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.