Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to calculate difference between 2 consecutive rows within single column?

$
0
0

I have a table named ShowSchedule. Attribs are as follows,

ShowID INT PRIMARY KEY

ShowDate DATE

ShowTime TIME

NameofShow NVARCHAR(100)

I have records order by ShowTime in a table.....Now I want to calculate duration of each and every show.....which should be the difference between two consecutive shows.....any idea?

ShowID ShowDate       ShowTime                  NameofShow

10007    2013-09-08    01:30:00.0000000    Safe House (2008)
10008    2013-09-08    03:30:00.0000000    Hanna
10009    2013-09-08    06:00:00.0000000    War Horse
10010    2013-09-08    08:00:00.0000000    Hot Shots
10011    2013-09-08    10:00:00.0000000    Van Helsing
10012    2013-09-08    12:30:00.0000000    The Mummy
10013    2013-09-08    14:30:00.0000000    Terminator 3: Rise of the Machines
10014    2013-09-08    16:30:00.0000000    Rise of the Planet of the Apes


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>