我的表格如下:
userid pagetag time
111 1-2 19:08:02
111 1-2 19:09:03
111 1-2 19:10:11
111 1-2 19:10:12
113 1-2 13:02:04
113 1-2 13:04:03
113 1-2 13:04:08
115 1-2 14:08:56
115 1-2 14:14:22
115 1-2 14:14:25
我希望在同一用户标识中获取时间间隔超过60秒的用户标识。结果如下:
userid count
111 2
113 1
115 1
答案 0 :(得分:0)
您可以使用子查询:
SELECT
LogTable.userid,
Count(LogTable.time) AS Over60
FROM
LogTable
WHERE
DateDiff("s", [time],
Nz((Select Top 1 [time]
From LogTable As T
Where T.userid = LogTable.userid And T.time > LogTable.time
Order By T.time Desc),[time])) > 60
GROUP BY
LogTable.userid;