我正在使用 Select MAX 来获取最新的 [CreatedDateTime] 但是我在查询中得到重复而不是单个结果?我的 SQL 查询如下所示;
SELECT DISTINCT
i.[RecID] as AssigneeID,
t.[Owner],
t.[CreatedDateTime]
FROM Incident as i
Left Join Task as t
On i.[RecID] = t.[ParentLink_RecID]
WHERE
(t.[CreatedDateTime] IN (SELECT MAX(t.[CreatedDateTime])
FROM Task as t
GROUP BY t.[ParentLink_RecID]))
AND i.[Status] <> 'Closed'
AND t.[OwnerTeam] IS NOT NULL
Order By i.[RecID] ASC
从重复问题添加的示例数据:
AssigneeID CreatedDateTime
E94D6F547A73430BA75758C79D5BD8DB 28/05/2013 10:25
E94D6F547A73430BA75758C79D5BD8DB 28/05/2013 10:32
CB208EB6BCC24E1791F946F01D6AF97B 26/03/2013 15:14
CB208EB6BCC24E1791F946F01D6AF97B 16/05/2013 15:20
BE14926E300E45AD8A9A949114CE8026 29/04/2013 10:27
BE14926E300E45AD8A9A949114CE8026 01/05/2013 08:41
任何援助将不胜感激