日期:2014-05-17 浏览次数:20559 次
select count(*) as '总人数',sum(case when b.studentresult>=60 then 1 else 0 end) as '通过人数'
from student a
left join result b on a.studentno=b.studentno
left join subject c on b.subjectid=c.subjectid
where c.subjectName='设计MySchool数据库'
and exists(select 1
from (select studentno,max(examdate) as examdate from result group by studentno)t
where b.studentno=t.studentno and b.examdate=t.examdate
)