but i see i need to add a where statement in the inner select somehow to match the patients.
update #Patients set LatestVisit = h.VisitDate, Id = h.id from (select top 1 fd.PersonId, fd.id, fd.VisitDate from dbo.Trombos_FollowUpData fd order by fd.Visitdate desc ) h where h.Personid = #Patients.PersonId
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
22 Experts available now in Live!