我正在尝试设置一个条件语句,该条件语句将确定要使用的WHERE子句。
我需要检查2个单独的条件,“与”的每一侧都要检查一个条件,如果结果大于1,则使用特定的语句,否则请不使用任何内容
类似此逻辑,但在pdw sql中
WHERE
if cte1.counte > 1 then 'cte1.built is not null' else ''
AND
if cte2.countd > 1 then 'cte2.demo is not null' else ''
可能的组合:
WHERE CTE1.BUILD IS NOT NULL
WHERE CTE1.BUILD IS NOT NULL AND CTE2.DEMO IS NOT NULL
WHERE CTE2.DEMO IS NOT NULL
BLANK
这可能吗?
预先感谢
答案 0 :(得分:2)
类似这样的东西:
WHERE (cte1.counte > 1 and cte1.built is not null or cte1.counte <= 1) and
(cte2.countd > 1 and cte2.demo is not null or cte2.countd <= 1)