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
)