CodePudding user response:
1. To find out first scored an average of each course
Select the convert (float, the sum (grade))/convert (float, count (grade)) as avgGrae, cno from studentclass group by cno
2. To find a way to let the result to the select statement
The select s.s no, s.s name, Arthur c. name, sc. Grade the from student s
Inner join
Studentclass sc on s.s no=sc. Sno
Inner join
Class c on sc. Cno=Arthur c. no -- -- so far is to get all the data, and then connected to the detected average
Inner join
(select the convert (float, the sum (grade))/convert (float, count (grade)) as avgGrae, cno from # studentclass group by cno) gra
On sc. Cno=gra. Cno
Where the convert (float, sc. Cno) & gt; Gra. AvgGrae -- -- through the result column is greater than average respectively, and to filter the data
CodePudding user response:
Finally the where to write wrong,Where the convert (float, sc. Grade) & gt; Gra. AvgGrae