17,090
社区成员
发帖
与我相关
我的任务
分享
with table1 as(
select 1 a,'2' b,3 c,null d from dual union all
select 2,'s',8,null from dual union all
select 3,'a',5,2 from dual union all
select 4,'b',null,9 from dual)
select * from table1
where a>2 and
(case when c is null then 5 else c end)>4 --如果c为null 就是5>4 不为null就是c>4
and (case when d is null then 6 else d end)<7 --如果d为null 就是6<7 不为null就是d<7
A B C D
---------- - ---------- ----------
3 a 5 2
select * from table1
where A>2 and
(case when C is null then 1=1 else C>4 end)
and (case when D is null then 1=1 else D <7 end)
select * from table1
where A>2 and
(case when C is null then 1=1 else then C>4)
and (case when D is null then 1=1 else then D<7)