以下代码应该能够向我返回一些不包含以下内容的记录:
RequestStatus <> 'Submission'
OR RequestStatus <>'Pre-CRC submission'
OR RequestStatus <>'CCT Review'
上面列出的每个项目都是来自下拉菜单的菜单项目。最终结果中不应列出其中的一个。但是,结果中列出了这些项目。有人知道我在这里做错什么吗?
Select
RequestStatus,
IncidentID,
max(LastModifiedDateTimeJ) as 'newfield',
OwnedByTeamJ,
DetailsJ,
Status,
OwnedByTeam
from IncidentTicket
where
CAST(CreatedDateTime as DATE) >='05-01-2019'
AND JournalTypeName like '%Journal - Note%'
And OwnedByTeamJ like '%C - OS Review%'
AND
(
RequestStatus <> 'Submission'
OR RequestStatus <>'Pre-CRC submission'
OR RequestStatus <>'CCT Review'
)
group by RequestStatus,IncidentID,OwnedByTeamJ
,DetailsJ,Status, OwnedByTeam
谢谢
答案 0 :(得分:1)
使用:
where RequestStatus not in ('Submission','Pre-CRC submission','CCT Review')
手术室把你搞砸了
答案 1 :(得分:1)
条件
RequestStatus <> 'Submission'
OR RequestStatus <>'Pre-CRC submission'
OR RequestStatus <>'CCT Review'
总是为真。您可能打算使用:
RequestStatus <> 'Submission'
AND RequestStatus <>'Pre-CRC submission'
AND RequestStatus <>'CCT Review'
如果值不同于所有给定值,则实际上可以为真。