WHERE
--from TABLE.PARAMETER1
(b.is_ot_paycode = 'Y' OR
-- from variableA
b.is_ot_paycode = 'Y')
AND
-- from TABLE.PARAMETER1
(b.is_wh_paycode = 'Y' OR
-- from variableA
b.is_wh_paycode = 'Y')
-- from variableB
AND b.is_ot_paycode = 'Y'
如何在我的CASE
子句中创建WHERE
语句
b.is_wh_paycode = 'Y' (from variableA) and
b.is_ot_paycode = 'Y'(from variableB)
b.is_wh_paycode (from TABLE.PARAMETER1) would always be equal to 'N'?
答案 0 :(得分:1)
您不需要case
。
WHERE (b.is_wh_paycode <> 'Y' or b.is_ot_paycode <> 'Y' or b.is_wh_paycode = 'N')
您可以将其编写为case
:
WHERE b.is_wh_paycode = (case when b.is_wh_paycode = 'Y' and b.is_ot_paycode = 'Y'
then 'N' else b.is_wh_paycode
end)
但它不一定更清楚。
注意:这两个都假设列不会采用NULL
值。如果他们这样做,那么SQL需要考虑到这一点。