Monday, July 23, 2018

SQL Script NOT IN with multiple fields


SELECT COUNT(*)

FROM dbo.ssFields

WHERE field7='Legal'

AND  ArchiveID =  '1' --Travel Agency

AND (Field1 + ' ' + Field3 + ' ' + CONVERT(VARCHAR,Field5, 23) + ' ' + field12 + ' ' + field18) NOT IN(

       SELECT (Field1 + ' ' + Field3 + ' ' + CONVERT(VARCHAR,Field5, 23) + ' ' + field12 + ' ' + field18) AS CompareString

       FROM dbo.ssFields

       WHERE field7='Legal'

       AND  ArchiveID =  '8' --Travel Agency - Date Fix

)

No comments:

Post a Comment