A B C FLM123 Down 1/8/2014 09:08 FLM124 Down 1/8/2014 11:08 FLM125 Down 1/8/2014 16:08 FLM126 UP 1/8/2014 12:08 FLM127 Bottom 1/8/2014 11:08 FLM128 Level 1/8/2014 10:08 FLM129 Matched 1/8/2014 12:08
A B C FLM123 Down 1/8/2014 09:08 FLM125 Down 1/8/2014 16:08 FLM126 UP 1/8/2014 12:08 FLM127 Bottom 1/8/2014 11:08 FLM128 Level 1/8/2014 10:08 FLM129 Matched 1/8/2014 12:08
SELECT a,b, c, LEAD(c) OVER (ORDER BY a) NextRow,datediff(HOUR,c,isnull(LEAD(c) OVER (ORDER BY a),c)) as TimeDiff FROM #TestTable
Lead
Lag
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)