【发布时间】:2016-12-19 08:20:20
【问题描述】:
是否可以在 where 子句中使用 case when 条件来过滤 select 语句。 例如:
Select * from table_name
where source ='UHC'
and
to_char(termdate,'YYYYMM') <= '201603';
但我希望第二个过滤条件仅在策略编号为“1”时才起作用。例如:
case when policy_number = '1' then to_char(termdate,'YYYYMM') <= '201603';
如果策略编号不是 1,那么只有第一个 where 子句应该起作用,但如果策略编号是 1,那么两个 where 子句都应该起作用。 我希望我把我的情况说清楚了。
【问题讨论】: