having是分组(group by)后的筛选条件,分组后的数据组内再筛选;where则是在分组前筛选。
正确写法:select student_id, avg(score) as avgscore from student_score group by student_id having avgscore>60;
错误写法:select student_id, avg(score) as avgscore from student_score where avgscore>60 group by student_id;