如果您有一个名为 [YourTable] 的表,其中包含数据...
id date
------ ----------
510010 2013-09-12
510010 2013-09-10
510010 2013-09-05
510010 2013-09-14
510012 2013-09-14
510012 2013-09-10
...然后您可以在 Access 中创建一个名为 [CalculateDaysAway] 的已保存查询...
SELECT
[id],
[date],
Abs(DateDiff("d", [date], Date()) AS DaysAway
FROM YourTable
...(在 2013 年 9 月 11 日运行时)返回
id date DaysAway
------ ---------- --------
510010 2013-09-12 1
510010 2013-09-10 1
510010 2013-09-05 6
510010 2013-09-14 3
510012 2013-09-14 3
510012 2013-09-10 1
现在您可以使用该查询作为查询返回最近日期的基础...
SELECT
CalculateDaysAway.[id],
CalculateDaysAway.[date]
FROM
CalculateDaysAway
INNER JOIN
(
SELECT
[id],
MIN(DaysAway) AS MinOfDaysAway
FROM CalculateDaysAway
GROUP BY [id]
) AS MinDays
ON CalculateDaysAway.[id] = MinDays.[id]
AND CalculateDaysAway.DaysAway = MinDays.MinOfDaysAway
...(在 2013 年 9 月 11 日运行时)返回
id date
------ ----------
510010 2013-09-12
510010 2013-09-10
510012 2013-09-10