Using SSRS 2008 R2
I'm having some problems working out how to look for records that are in one query and not another.
I've tried NOT EXISTS, NOT IN and LEFT JOIN.
When I try the sub query on its own it works fine, but when I join it to the first query with NOT EXISTS it returns no records (there should be around 5000 records returned).
I found this post SQL "select where not in subquery" returns no results and whilst I'm not sure I understand all of the answers (!) I did try filtering out any nulls that either query returns.
FYI it's not enough just to look for people who are in the first query where document type is not = 4 as I am doing something more complicated with additional columns I need for a table - I thought it would be easier for someone to point me in the right direction if I distilled the query down to that shown below.
Thanks, Eileen
SELECT
  TblPeople.PeopleId
  ,TblPeople.FirstName
  ,TblPeople.Surname
FROM 
TblPeople
WHERE TblPeople.PeopleId IS NOT NULL
AND NOT EXISTS 
(SELECT
  TblPeople.PeopleId 
FROM
  TblPeople
  INNER JOIN TblDocument 
    ON TblDocument.DocumentPeopleId = TblPeople.PeopleId
WHERE
  TblDocument.DocumentType = 4 
  AND TblPeople.PeopleId IS NOT NULL)