h******3 发帖数: 351 | 1 stu_name, class_id, time, grade
A 101 1 90
B 101 1 80
A 101 2 100
A 102 1 80
B 102 1 50
B 102 2 70
time 是第几次take这门课, assume一门课只能retake一次.
写SQL, 算出每门课average improvement for students.
翻出曾经收藏的这个题目,当时就没想清楚, 什么是 average improvement for
students. 那没重修过的酸有improvement么?
做过的给个hint吧? 谢谢. | x*****p 发帖数: 1707 | 2 You need to define what is "average improvement for students" | f*******h 发帖数: 53 | 3 with FirstTime as(
select stu_name,classID,GradeOne
from t
where time=1
),
SecondTime as(
select stu_name,classID,GradeTwo
from t
where time=2
)
select avg(s.GradeTwo-f.GradeOne)
from FirstTime f,
SecondTime s
where f.stu_name=s.stu_name
and f.classID=s.classID |
|