title: SQL WHERE != clause results in no results when the WHERE returns nothing
body: <p>I have this SQL query:</p>
  
  <pre><code>USE thr_clinic
  GO
  WITH CompleteSchedule AS (
      SELECT  U.ID as UserID, U.Role, U.Surname, U.Clinic, TS.ID as TimeSlotID, TS.TimeSlot
      FROM    Users U
          CROSS JOIN  TimeSlots TS
  )
  SELECT  CS.*
  FROM    CompleteSchedule CS
      LEFT JOIN   Appointments A 
          ON A.MedicalStaffID = CS.UserID 
          AND A.TimeSlot = CS.TimeSlotID 
          AND A.AppDate = CONVERT(DATE,DATEADD(day, 3, GETDATE()))
  WHERE   A.ID is null 
          AND CS.Role != 'Patient' 
          AND CS.Clinic = (SELECT Clinic FROM Users WHERE Users.ID = 1)
          AND CS.UserID != (SELECT StaffID FROM DaysOff WHERE DayOff = CONVERT(DATE,DATEADD(day, 3, GETDATE())))
  ORDER BY    CS.UserID, CS.TimeSlotID
  </code></pre>
  
  <p>However, with the <code>WHERE</code> just before the <code>ORDER BY</code>, if that returns empty (meaning no one is off on the given date) the overall query returns nothing; but if there is a result (someone off), they won't appear, everyone else will and it works fine. </p>
  
  <p>I assumed if it returned empty then it would show everyone, as <em>empty</em> isn't a <em>userID</em> it can not show. </p>