From: Claudio Nanni Date: April 1 2009 3:19pm Subject: Re: Total logged in time List-Archive: http://lists.mysql.com/mysql/216972 Message-Id: <53bcf3a60904010819s43cbd41q6948d727110dc5a9@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=000e0cd25152ea784e04667fd736 --000e0cd25152ea784e04667fd736 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Just a hint: Given the user 'User' and given no missing login/logout event logging you can retrieve the total amount in seconds he was logged on with the following formula: SELECT (SELECT SUM(time_to_sec(time_stamp)) as logoutTime from logevents where event='logout' and userid='User' ) - (SELECT SUM(time_to_sec(time_stamp)) as loginTime from logevents where event='login' and userid='User') this can surely be developed with grouping by user and filtering by time, this is just the basic function. Cheers Claudio 2009/4/1 Tom Scheper > Hi, > > I have a table like so > > id autoinc > userid int > action enum ('login', 'logout' ) > timestamp > > -- > > Is it possible to perform a mysql query that gets the total logged in > time for any one user on any one particular day/week/month? And how? > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: > http://lists.mysql.com/mysql?unsub=claudio.nanni@stripped > > --000e0cd25152ea784e04667fd736--