select count(*) from (select t1.sId from (select sId, case when cId=1 then score else 0 end as c1_score from SC) t1 left join (select sId, case when cId=2 then score else 0 end as c2_score from SC) t2 on t1.sId=t2.sId left join (select sId, case when cId=3 then score else 0 end as c3_score from SC) t3 on t2.sId=t3.sId group by t1.sId having avg(t1.c1_score+t2.c2_score+t3.c3_score)>60) t4