我的错误在哪里?
select dr.ders_code, dr.year,
case when dr.muf_sq is not null then
case when (select muf_sq_id from mufredat_sq m join ders_stud_ref dr on dr.muf_sq = m.muf_sq_id) = dr.muf_sq then dr.muf_sq end
end
from ders_stud_ref dr
答案 0 :(得分:1)
第一个错误是
select muf_sq_id
from mufredat_sq m
join ders_stud_ref dr on dr.muf_sq = m.muf_sq_id
可能会返回多行
我认为你需要像
这样的东西select dr.ders_code, dr.year,
case when dr.muf_sq is not null then
case when exists (select muf_sq_id
from mufredat_sq m
where dr.muf_sq = m.muf_sq_id) then dr.muf_sq end
end
from ders_stud_ref dr