27. September 2019 15:20
30. September 2019 08:22
SELECT *
FROM
[xxx Test$Sales Header Archive] sa
WHERE
sa.[Version No_] =
(SELECT TOP 1 [Version No_]
FROM [xxx Test$Sales Header Archive] sa2
WHERE
sa2.[Document Type] = sa.[Document Type]
and sa2.[No_] = sa.No_
and sa2.[Doc_ No_ Occurrence] = sa.[Doc_ No_ Occurrence]
ORDER BY [Version No_] DESC)
SELECT [Document Type], No_, MAX([Version No_])
FROM
[xxx Test$Sales Header Archive] sa
GROUP BY [Document Type], No_, [Doc_ No_ Occurrence]