select values from interval

From: Josep Sanmartí <josep(dot)sanmarti(at)openwired(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: select values from interval
Date: 2005-07-04 12:00:57
Message-ID: 1120478457.3506.17.camel@josep
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I've this table: am_conn(mac, user_ip, start_time, end_time). Each time
a user connects with a remote server a new row is added, when the user
is disconnected the end_time field is set.

Now, I want to know if there is a way (sql statement) to know how many
connections are up during an interval time, for example 60 segs, and to
repeat this interval from a beginning date to end date. I think it
should be something like:
SELECT COUNT(*)
FROM am_conn
WHERE start_time between '2004-01-01 10:28:00.000'
AND end time '2005-01-01 10:28:00.000'
GROUP BY .....something.....

I made some tests but I can't obtain the correct statement. Maybe,
probably, it should be done without group by.

Thanks.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Zac 2005-07-04 12:47:16 Re: Help on Procedure running external function
Previous Message Andreas Kretschmer 2005-07-01 20:19:35 Re: [despammed] Re: 'show full processlist' in postgres?