I have this query to find the latest completed job date, however it doesnt always find the last, and can return more than 1 result, why cant I get one result returnedSELECT P.PropID, MAX(ASV.completion_date) AS LatestCP12Date, P.Area, COUNT(DISTINCT P.UPRN) AS CP12CountFROM dbo.servicing_jobs AS ASV INNER JOIN dbo.vwProperties AS P ON ASV.prop_seql = P.PropIDGROUP BY P.PropID, P.Area, ASV.completion_dateHAVING (MAX(ASV.completion_date) IS NOT NULL)
Or is there a better way to do this?