Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Pryach
Starting Member
3 Posts |
Posted - 2011-01-19 : 12:09:35
|
I have a table that looks like this:id profileid action datetime1 524123 STARTED 01/19/2011 08:00:002 524123 FINISHED 01/19/2011 08:30:003 182901 STARTED 01/19/2011 09:00:004 182901 FINISHED 01/19/2011 09:15:005 819102 STARTED 01/19/2011 09:30:006 819102 FINISHED 01/19/2011 10:00:007 284102 STARTED 01/19/2011 10:05:00 I want to find out what the average time is to go from Started to Finished. We have three people being finished, thirty minutes, fifteen minutes, and thirty minutes. So the average time is 25 minutes (although I'd like the results in seconds, 1500).I'm pretty new to SQL so if someone could help me out I would appreciate it. I'm sure I'm going to have to use DATEDIFF and AVG, I'm just not sure how to get the start and end dates in there.Thanks! |
|
|
michael.appleton
Posting Yak Master
160 Posts |
Posted - 2011-01-19 : 12:29:25
|
| You'll have to do a self join on profileid, then use datediff, then just do avg function |
 |
|
|
|
|
|