SELECT
yt1.[timestamp] AS StartTime,
MIN(yt2.[timestamp]) AS EndTime,
DATEDIFF(s, yt1.[timestamp], MIN(yt2.[timestamp])) AS DifferenceInSeconds
FROM
yourTable yt1
LEFT JOIN yt2 ON yt1.[timestamp] < yt2.[timestamp]
WHERE
yt1.Col1 IS NULL
OR yt1.Col2 IS NULL
...
OR yt1.Col20 IS NULL
OR yt2.Col1 IS NULL
...
OR yt2.Col20 IS NULL
GROUP BY yt1.[timestamp]
在同一个查询中,当前输出类似于
18-05-2012 20:07
18-05-2012 20:17
18-05-2012 20:27
18-05-2012 20:37
等有10分钟的差距,连续的差距,我们应该看到18-05-2012 20:07作为开始时间,18-05-2012 20:37作为结束时间和差距在40分钟40.你能请帮助