Hi,
I have a situation like this.I have a user login data table called LogTable where i have a set of Login, Logout date time details against a particular userid.The structure of LogTable is like this.
LogId (Primary key)
UserId(foreign key from user table)
Login_time(datetime)
LogoutTime(datetime)
The rows in this table is like this
LogId UserId LoginTime LogOutTime
1 23 5/20/2008 12:40AM 5./20/2008 1:10 AM
2 23 5/20/2008 1:15 AM 5/20/2008 2:10 AM
3 23 5/20/2008 2:15 AM 5/20/2008 3:20 AM
4 23 5/20/2008 3:40 AM 5/20/2008 4:00 AM
Here we can see a series of login, logouts by userid 23 , i need a sql query to calculate the total time the user spents in logging in (ie, sum (LogOutTime - LoginTime) for the 4 records, and also the total time in logging out for example the time the user logged out for the first time is 5/20/2008 1:15 - 5/20/2008 1:10 ie, 5 minutes.How can i find this using a sql query ? Please help
Start Free Trial