hi,
table raw_requests
site_id session_id request_id logged_date_time
--------------------------------------------------------------------------
1 1 1 2004-01-01 12:00:31
1 1 2 2004-01-01 12:01:12
1 1 3 2004-01-01 12:01:49
1 2 1 2004-01-01 12:02:01
1 2 2 2004-01-01 12:02:34
I need to do a SELECT query that groups all rows by their session_id and in the process also subtracts the last date of a session with the first date of the same session... Is that possible?
So i need to return the following results based on the example table above:
site_id session_id total_time
---------------------------------------------
1 1 00:01:18
1 2 00:00:33
I'm able to return those results (but without the total_time) with the following query:
SELECT site_id, session_id
FROM raw_requests
GROUP BY session_id, site_id