(select stuid from a where a.classd=b.classd and stulb='01' order by rtime desc) x 这个要加上表b才行吧。
select case when b.classd = '001' then (select stuid from (select stuid from a where a.classd = classd and stulb = '02' order by rtime desc) x where rownum = 1) when b.classd = '002' then (select stuid from (select stuid from a where a.classd = classd and stulb = '01' order by rtime desc) x where rownum = 1) else '0' end as zzrx from b
when b.classd = '001' then
(select stuid
from (select stuid
from a
where a.classd = classd
and stulb = '02'
order by rtime desc) x
where rownum = 1)
when b.classd = '002' then
(select stuid
from (select stuid
from a
where a.classd = classd
and stulb = '01'
order by rtime desc) x
where rownum = 1)
else
'0'
end as zzrx
from b
不知道是不是这样,等大神解答