I have a query where i want to get a distinct description by the latest date entered and the descriptions ID. I can get the disctinct part but i run into trouble with trying to get the ID since im using MAX on the date. Here is the query:
SELECT DISTINCT Resource.Description, MAX(arq.DateReferred) AS DateReferred, arq.AssessmentResourceID FROM AssessmentXResource AS arq INNER JOIN Resource ON arq.ResourceID = Resource.ResourceID INNER JOIN Assessment AS aq INNER JOIN [Case] AS cq ON aq.CaseID = cq.CaseID INNER JOIN [Plan] AS pq ON cq.CaseID = pq.CaseID ON arq.AssessmentID = aq.AssessmentID WHERE (pq.PlanID = 22) GROUP BY Resource.Description, arq.AssessmentResourceID ORDER BY Resource.Description
Im sure its simple but im not seeing it.
1 Answer