I'm attempting to execute the following query to return a data set where the Updated Date is the most recent. I'm thinking my joins are causing the issue, but I'm not sure, and have not made any progress.
SELECT wd.SAPID, rd.RequestID, vd.VersionTableID,rd.ProjectReference,contactinfo.FirstName,contactinfo.LastName,
wd.ActualEndDate, wd.IsIndependentContractor,we.AssignmentStartDate, vd.VersionNo, we.CreatedDate, we.UpdatedDate
FROM RequestDetails rd
INNER JOIN WorkerDetails wd ON rd.RequestTableID = wd.RequestTableID
INNER JOIN WorkerExtension we ON we.WorkerID=wd.WorkerID
INNER JOIN dbo.Address_Info addressinfo ON addressinfo.WorkerID = wd.WorkerID
INNER JOIN dbo.Contact_Info contactinfo ON contactinfo.WorkerID = we.WorkerID
INNER JOIN VersionDetails vd ON vd.RequestTableID = rd.RequestTableID
WHERE we.AssignmentEndDate >= '2/16/2016' AND EndDate <= '2/20/2016' AND contactinfo.FirstName = 'Barsegyan' AND we.UpdatedDate = (SELECT MAX(we.UpdatedDate))
GROUP BY wd.SAPID, rd.RequestID, vd.VersionTableID,rd.ProjectReference,contactinfo.FirstName,contactinfo.LastName,
wd.ActualEndDate, wd.IsIndependentContractor,we.AssignmentStartDate, EndDate, vd.VersionNo, we.CreatedDate, we.UpdatedDate