Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding average time

Status
Not open for further replies.

see123

Programmer
May 11, 2001
28
0
0
US
Hi,

How to find out the Average login time.

My Result set

NAME ID STATUS LOGINDATE
abc 1234 LOGN 2002-12-02 11:19:29.207
abc 1234 LOGOUT 2002-12-02 11:21:29.207
abc 1234 LOGIN 2002-12-02 11:22:32.200
abc 1234 LOGIN 2002-12-02 11:30:32.192
abc 1234 LOGOUT 2002-12-02 11:28:20.160
abc 1234 LOGOUT 2002-12-02 11:32:14.100


 
SELECT t0.id, avg(sum(t1.logindate) - sum(t2.logindate))
FROM myTable t0
LEFT JOIN myTable t1 ON t0.id = t1.id and t1.status = "LOGIN"
LEFT JOIN myTable t2 ON t0.id = t2.id and t2.status = "LOGOUT"
GROUP BY t0.id



Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top