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

Finding the time spent between two consecutive actions

$
0
0

Hi All,

I have a table with the following columns:

Date datetime

Queue varchar(50)

Agent varchar(50)

Action varchar(10)

Records are inserted into this table in sequential order (based on Date), and the data would look something like this:

2014/04/30 9:00  Queue1  BillyBob  LOGIN

2014/04/30 9:05  Queue1  BillyBob  PAUSE

2014/04/30 9:10  Queue1  BillyBob  LOGOUT

2014/04/30 9:10  Queue1  BillyBob  LOGIN

2014/04/30 9:45  Queue1  BillyBob  LOGOUT

What i'm trying to get is the time spent between each successive action. So for example, the output should return something like :

Date  Queue  Agent  Action  Duration (mins)

2014/04/30 9:00  Queue1  BillyBob  LOGIN

2014/04/30 9:05  Queue1  BillyBob  PAUSE  5

2014/04/30 9:10  Queue1  BillyBob  LOGOUT  5

2014/04/30 9:10  Queue1  BillyBob  LOGIN  0

2014/04/30 9:45  Queue1  BillyBob  LOGOUT  35

Any help is appreciated! Thanks in advance.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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