我正在尝试检查
SELECT
*
FROM
table
WHERE
CASE
WHEN startdate IS NULL
THEN updatedon >= enddate
ELSE updatedon BETWEEN startdate AND enddate
我在“>”条件下的 THEN 块中遇到错误。
您可以使用布尔逻辑代替case
表达式:
select *
from table t
where (startdate is null and updatedon >= enddate) or
(startdate is not null and (updatedon >= startdate and updatedon <= enddate)
);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句