有条件的 Where 语句

Conditional Where Statement

我正在尝试设置一个条件语句来确定要使用哪个 WHERE 子句。

我需要检查 2 个单独的条件,一个在 AND 的每一侧,如果结果大于 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

这可以吗?

提前致谢

像这样:

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)