jeudi 16 juin 2016

SQL: Difference Between Current Row of StartTime Column And Previous Row of EndTime Column

I have a Table in which there are multiple columns but I need to find the Difference Between Current Row of StartTime Column And Previous Row of EndTime Column.

Example is the Following output.

Batch Number    Start Time  End Time        Difference

100004          8:00:00     8:03:30        
100005          8:05:00     8:07:00         00:01:30
100006          8:08:40     8:15:00         00:01:40
32141           8:18:00     8:22:45         00:03:00
84230           8:25:10     8:33:42         00:02:25
23444           8:40:00     8:43:00         00:06:18
100001          8:50:00     8:52:00         00:07:00            

I am new to SQL and am using SQL SERVER 2008 R2.

Please help me to get the output in Simple Select Query.

Aucun commentaire:

Enregistrer un commentaire