我在Access中有一个表格,如下所示
SI Number Time
1.14172E+20 13:30:35
1244066650 18:58:48
1244066650 19:03:12
1244066650 19:05:50
01724656007_dsl 22:15:20
01724656007_dsl 22:18:00
01724656007_dsl 22:24:28
1141530407 10:27:49
1141530407 10:29:13
要求同一表中的输出
SI Number Time Diff
1.14172E+20 13:30:35
1244066650 18:58:48
1244066650 19:03:12 0:04:24
1244066650 19:05:50 0:02:38
01724656007_dsl 22:15:20
01724656007_dsl 22:18:00 0:02:40
01724656007_dsl 22:24:28 0:06:28
1141530407 10:27:49
1141530407 10:29:13 0:01:24
我要求好像SI号列中的第一条记录等于第二条记录而不是时间列的记录2 - 差异列记录2中时间列的记录1记录1将保持空白
需要紧急帮助 维杰
答案 0 :(得分:0)
看看像
这样的东西SELECT *,
DatePart("h",DiffVal) & ":"&
DatePart("n",DiffVal) & ":" &
DatePart("s",DiffVal) AS DiffVals
FROM (
SELECT t1.*,
[t1].[Time]-
(
SELECT TOP 1
Time
FROM Table1
WHERE Table1.SINumber = t1.SINumber
AND Table1.Time < t1.Time
ORDER BY Table1.Time DESC
) AS DiffVal
FROM Table1 AS t1
) AS Tables;