sql where条件添加判断 case when… then…else…end,示例说明
select * --count(ttt.id)
from t_yhxx_zdcsqd_sj ttt
where ttt.rwqd_id = '40268fcb7319bdec017326f537f223a0'
and case
when to_char(sysdate, 'yyyy') = '2020' then
ttt.state_1
when to_char(sysdate, 'yyyy') = '2021' then
ttt.state_2
else
ttt.state_3
end = '1'
当前年份如果是2020或者2021或者其他生效的where条件