ник: shanemac51
возможно так
SELECT (T1.Dogovor_Id & '=' & T1.DataStatusChanged) As LastIdData, Max(T2.Status_ID) AS LastStatus_Id
FROM Query1 AS T2 INNER JOIN (SELECT T1.Dogovor_Id, Max(T1.DataStatusChanged) AS DataStatusChanged
FROM Query1 AS T1 GROUP BY T1.Dogovor_Id) AS T1
ON (T2.DataStatusChanged = T1.DataStatusChanged) AND (T2.Dogovor_Id = T1.Dogovor_Id)
GROUP BY T1.Dogovor_Id & '=' & T1.DataStatusChanged;
|
затем выбрать из таблицы согласно
T1.Dogovor_Id & '=' & T1.DataStatusChanged