日期:2014-05-17  浏览次数:20511 次

T-sql 相关子查询出了点问题求大神

我圈住的那个是相关子查询 , 为什么不能用不了 求大神 ?

------解决方案--------------------
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
  )