`

case 的操作

 
阅读更多
select i.id, i.managebodyno, i.sttime, i.totalincome,
i.totalexpense, i.resultsr, i.income, i.reserve, i.glxjk,
i.realincome,
(case
  when MANAGEBODYID is not null then m.managebodyname
  when DEPT_TWO_ID is not null then o2.orga_name
  when DEPT_THREE_ID is not null then o3.orga_name
end) as orgaName
from eos_incomestatistics i
left join eos_managebody m on m.managebodyid = i.managebodyno
left join scy_organization o2 on o2.orga_id = m.dept_two_id
left join scy_organization o3 on o3.orga_id = m.dept_three_id
where (m.managebodyid ='' or '' is null)
and (i.sttime = '' or '' is null)
and (m.dept_two_id  = '' or '' is null)
and (m.dept_three_id  = '' or '' is null)
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics