Topic: Query average score of 60 points or greater number of students and the student's name and student grade point average
Mentioned here average, avg use according to groups of students, and then averaged points, there should be investigated group by using a function of polymerization should be greater than 60 minutes after use in accordance with the result of having a packet filter
group by the use of aggregate functions having been written on the blog post
So write sql in the following:
SELECT studentid,AVG(score) AS a FROM student_score GROUP BY studentid HAVING a>60
To find a complete student information, should be carried out to join the student table student:
Complete sql:
SELECT b.id, b.stdentname,a FROM student AS b JOIN
(SELECT studentid,AVG(score) AS a FROM student_score GROUP BY studentid HAVING a>60)c
ON b.id = c.studentid
search result:
Pondering a question: Why join here did not use left join right join it?