I'm trying to get rows from tblReqInfo when ReqID is between 5 and 8 and there is NO corresponding row in tblSomeTable
SELECT *
FROM tblReqInfo
WHERE (RI_ReqID BETWEEN 5 AND 8)
AND
CASE
WHEN NOT EXISTS
(SELECT CC_ReqID
FROM tblSomeTable
WHERE (CC_UserID = @CC_UserID) )
THEN 1
ELSE RI_ReqID NOT IN (SELECT CC_ReqID
FROM tblSomeTable
WHERE (CC_UserID = @CC_UserID) )
END
ORDER BY RI_ReqID
Unfortunately, the query configuration wizard can't even parse this. Can anyone discern what query might work for me?