Be careful to be misled by answers to online interview questions

Source: Internet
Author: User
Recently, I wanted to find a job, so I began to make up my basic knowledge. I remember a gentleman on the Internet making a joke: "typing is fast, but I found that I forgot my keyboard layout. I have a lot of experience, but I found that I would not do the question. "It is true that many interview questions can take me for a moment. How nice if Google can carry it with you! Haha

Today, I found that there was a problem with one of the questions on the Internet. However, due to the fact that too many interview questions have caused me to be overwhelmed, I am not sure, but for the sake of scientific rigor ,, you can only test SQL by yourself. I found that, indeed, my method is correct, and the so-called answer on the internet is simply mistaken. After a search, I realized that someone had already discovered it .. The questions are as follows:

Create three tables to manage job business training information:
S (s #, Sn, SD, SA) s #, Sn, SD, and SA represent the student ID, Student name, organization, and student age respectively.
C (C #, CN) C #, CN represents the course number and Course name respectively.
SC (s #, C #, g) s #, C #, and G represent Student IDs, elective course numbers, and academic scores respectively.

4. Use standard SQL nested statements to query the names and units of trainees who take all courses
Popular answers on the Internet:
Select Sn, SD from S
Where [s #] In (
Select [s #] from SC
Right join
C On SC. [C #] = C. [C #] group by [s #]
Having count (*) = count ([s #])

AboveCodeIt is incorrect. The key is to understand the error of right join. The correct method is as follows (after debugging ):
Select Sn, SD from S
Where s #
In (select SC. s #
From SC, c
Where SC. C # = C. C #
Group by SC. s #
Having count (distinct (SC. C #))
= (Select count (*) from C ))

Therefore, we can give you a reminder that you must think more about these so-called answers and do not trust them too much. There is no standard answer on the Internet.

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.