Re: Grouping logs by ip and time

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Grouping logs by ip and time
Date: 2011-11-08 18:57:36
Message-ID: 4EB97BA0.5080300@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/08/11 10:48 AM, Raymond O'Donnell wrote:
> Would something like this work? -
>
> select ip, max("time") - min("time") as session_duration
> from log_table
> group by ip;
>
> This doesn't take the date into account - what happens if the session
> spans midnight? You can get around this by using a timestamp column
> instead of separate date and time.

he said a session always starts with 'action1', and presumably there can
be more than one session per day, so this won't work. the 'end' of a
session is presumably the previous action2|3|4|5 thats prior to the next
action1. I have no idea how you'd code this as a SQL query.

--
john r pierce N 37, W 122
santa cruz ca mid-left coast

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ascarabina 2011-11-08 19:00:45 Re: Grouping logs by ip and time
Previous Message Raymond O'Donnell 2011-11-08 18:54:48 Re: Grouping logs by ip and time