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