oracle 中 使用判断语句 case

select distinct(m.APPI_APP_ID),m.APPI_SEND_FLAG,biz.BIZ_TYPE_PROP_NAME
as APPI_APP_TYPE,prod.PRO_CAT_NAME,m.APPI_MC_FIRST_NAME,
m.APPI_MC_FAMILYNAME,m.APPI_MC_ID_NUMBER,m.APPI_STATE,
(case when
(m.appi_state = '8' and r.check_turn_flag = '1' ) then '1'
when
(m.appi_state = '18' and r.emp_turn_commit_flag = '1' and
r.turn_not_end_case_flag is null) then '2'
when (m.appi_state = '10'
and r.check_turn_commit_flag = '1' and
(r.emp_turn_date is null or
(r.check_turn_commit_date >
r.emp_turn_date))) then '2'
when
(m.appi_state = '10' and r.emp_turn_flag = '1' and
(r.check_turn_commit_date is null or (r.emp_turn_date >
r.check_turn_commit_date))) then '1'
else null end) as turn_flag,
stats.BIZ_TYPE_PROP_NAME as APPI_STATE_NAME,m.APPI_UPDATE_TIME,
m.NODE_INPUT_USERID,m.NODE_CHECK_USERID,m.NODE_RECORD_USERID,m.NODE_EMP_USERID,stats.BIZ_TYPE_PROP_NAME,''
as MATCH_FLAG,'' as RETURN_APP_ID
,r.workflowins_id
from iaps_main_appi

猜你喜欢

转载自jinpengaigo.iteye.com/blog/1609341