I have a subquery that pulls the correct records out. I want to then get the full rows from the original table so am using IN. Its not working though! Any ideas?SELECT MAX(dbo.Attendees.UniqueID) AS UniqueId FROM dbo.Attendees LEFT OUTER JOIN dbo.Attendees_Courses ON dbo.Attendees_Courses.AttendeeId = Attendees.UniqueID GROUP BY Attendees.UniqueId HAVING( COUNT(dbo.Attendees_Courses.UniqueID) = 0 )
returns44964499
butSELECT * FROM Attendees WHERE UniqueId IN( SELECT MAX(dbo.Attendees.UniqueID) AS UniqueId FROM dbo.Attendees LEFT OUTER JOIN dbo.Attendees_Courses ON dbo.Attendees_Courses.AttendeeId = Attendees.UniqueID GROUP BY Attendees.UniqueId HAVING( COUNT(dbo.Attendees_Courses.UniqueID) = 0 ))
returns no rows! What am I missing?