我需要在 WHERE 子句中使用 CASE 语句,例如:
WHERE p.resource_qry_seq = b.resource_qry_seq
AND p.resource_id = b.resource_id
AND (CASE
WHEN b.flexible_time IS NULL THEN
((b.activity_start >= p.activity_start AND b.activity_end < p.activity_end) OR
(b.activity_start > p.activity_start AND b.activity_end <= p.activity_end))
ELSE
b.activity_start > p.late_start
END)
我收到“缺少右括号”如何根据列中的值包含此类条件?
a 的谓词CASE
表达式(即后面的内容THEN
) 必须是一个值,而不是逻辑。你可以改写你的WHERE
条款如下:
WHERE
p.resource_qry_seq = b.resource_qry_seq AND
p.resource_id = b.resource_id AND
((b.flexible_time IS NULL AND
(b.activity_start >= p.activity_start AND b.activity_end < p.activity_end) OR
(b.activity_start > p.activity_start AND b.activity_end <= p.activity_end)) OR
(b.flexible_time IS NOT NULL AND b.activity_start > p.late_start))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)