SQL 服务器中的多个子句,其中所有列都不为零

Multiple clauses in SQL Server where all columns do not equal zero

SQL Server

中的table为例
col1, col2, col3, col4
 id1, 0.00, 0.00, 0.00
 id2, 0.00, 1.00, 0.00
 id3, 5.55, 2.22, 0.00
 id4, 0.00, 0.00, 0.00
 id5, 1.11, 2.22, -3.33

我想实现一个 WHERE 子句,这样当 col2、col3 和 col4 中的所有值都为零时,该行就会从结果中排除。

我试过添加以下 WHERE 子句
where col2!=0 and col3!=0 and col4!=0

这 return 只有 id5 行,而我要的是 return id2、id3 和 id5。

我知道 where 子句是错误的,但不确定还可以尝试什么。

我考虑过对各列进行求和,但这是不可取的,因为小数可以朝任一方向移动,即使填充了所有值,也可能偶尔为零

您的意图是:

where not (col2=0 and col3=0 and col4=0)

解释为 所有三个不全为零的行

where col2!=0 or col3!=0 or col4!=0

解释为 至少有一列非零的所有行