Interviewquestion_sqlserver_probl_ Check the names of students who have more than 80 points per course

Source: Internet
Author: User
Tags microsoft sql server management studio microsoft sql server management studio sql server management sql server management studio

Title: Use a SQL statement to find out the names of students who have more than 80 points per course.

Recently interviewed C # development engineer, met the above test database of the topic, I feel a bit difficult, no ideas, now will find the solution to organize as follows:

Files: Sqlquery1.sql

/*environment: Microsoft SQL Server 2012 tools: Microsoft SQL Server Management Studio database: Interview Data sheet: Grade Details: Name class Scor E Zhang San language 81 Zhang Three mathematics 75 Li four languages 76 John Doe Mathematics 90 Harry Language 81 Harry Mathematics 100 Harry English*/--Check out the names of students who have more than 80 points per course:--Method 1SELECT DISTINCTName fromGradeWHEREName not inch(SELECT DISTINCTName fromGradeWHEREScore<=  the);--Method 2SELECTName fromGradeGROUP  byName having MIN(score)>  the;--The name of the student whose average score is greater than 80:--Method 1SELECTName from(SELECT COUNT(*) asTSUM(score) asNum,name fromGradeGROUP  byName asAWHEREA.num>  the*T;--Method 2SELECTNameAVG(score) asSc fromGrade G1GROUP  byName having AVG(score)>  the;

Operation Result:

Result 1:

Result 2:

Result 3:

Result 4:

Above finishing, if have the mistake place or has the better method, please see a friend to correct, thank you!

Reference article:

Http://www.cnblogs.com/praglody/p/6854181.html?utm_source=itdadao&utm_medium=referral

Interviewquestion_sqlserver_probl_ Check the names of students who have more than 80 points per course

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.