mikev1976 Posted February 23, 2012 Share Posted February 23, 2012 This is my query: select EligibilityFirstName,EligibilityLastName,EligibilityDateOfBirth,ExternalUserId, u.NameFirst,u.NameLast,DateOfBirthfrom Member.Users as ujoin Outreach_Core.CallAppointments as ca on u.UserId=ca.CalleeIdwhere u.SponsorId='AC475310-87AC-471B-90F6-9F5600B3AD3B'and exists--check to see if call was made in the last week(select CallDate from Outreach_Core.Calls as c where c.CallDate >= @startDate and c.CallDate < @endDate and ca.callappointmentid=c.CallAppointmentId)and( exists(select * from Outreach_Core.Calls as cwhere ca.callappointmentid=c.CALLAPPOINTMENTID and c.CallResultTypeId=4)and ca.CallAppointmentStatusTypeId=3)order by u.NameLast So in my result set I get person that has the attached call dates. The way I understand the query they should not show up. They meet the conditions inside of the second exists statement but that is joined by an and to filter the call dates. The call dates for this user do not match the call date filter so why are they showing up? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 23, 2012 Share Posted February 23, 2012 The exists clause is true if the query returns any results at all, so that query is returning at least one record. Link to comment Share on other sites More sharing options...
mikev1976 Posted February 23, 2012 Author Share Posted February 23, 2012 You are correct. I see now. Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.