简体   繁体   中英

Filtering zero values only if both columns are zero

I need the table to exclude rows where rw.amount <> 0 AND rw.paid_subs <> 0 but still include any row that has values in either column.

I am rather clueless with SQL tables, so I have been blindly guessing at how to code this.

AND rw.amount <> 0 
AND rw.paid_subs <> 0

Your logic is correct, but using DeMorgan's Laws we can rewrite your exclusion logic as:

SELECT *
FROM yourTable
WHERE amount = 0 OR paid_subs = 0;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM