我需要一个相反的条件:
SELECT TAX.*
FROM TAX
JOIN STATUS ON TAX.TAX_ID = STATUS.TAX_ID
WHERE STATUS.VALUE = 'ACTIVE'
OR (STATUS.VALUE = 'COLLECTED' AND STATUS.COLLECTEDDATE >= '20000101')
我想要的是不符合where子句的记录。
我尝试过
SELECT TAX.*
FROM TAX
JOIN STATUS on TAX.TAX_ID = STATUS.TAX_ID
WHERE STATUS.VALUE != 'ACTIVE'
AND (STATUS.VALUE != 'COLLECTED' and STATUS.COLLECTEDDATE < '20000101')
但是看起来我缺少记录。我认为SQL Server会删除记录,并且怀疑它会删除括号。
我可以建议如何进行吗?
谢谢
答案 0 :(得分:0)
方式对
因此您的查询成为
084A0002D43D0D4426
因此您的查询成为
Select TAX.* from TAX
JOIN STATUS on TAX.TAX_ID = STATUS.TAX_ID
WHERE NOT
(STATUS.VALUE = 'ACTIVE'
OR (STATUS.VALUE = 'COLLECTED' and STATUS.COLLECTEDDATE >= '20000101'))