我有一个查询,我想通过输入的最新日期和描述 ID 获得不同的描述。我可以得到不同的部分,但我在尝试获取 ID 时遇到了麻烦,因为我在日期使用 MAX。这是查询:
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
我确定它很简单,但我没有看到它。