pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josep SanmartĂ­ <josep.sanmarti@openwired.net>
To: pgsql-sql@postgresql.org
Subject: select values from interval
Date: Mon, 04 Jul 2005 14:00:57 +0200
Message-ID: <1120478457.3506.17.camel@josep> (raw)

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.





view thread (2+ messages)  latest in thread

Message-ID: <1120478457.3506.17.camel@josep>
Permalink:  ../1120478457.3506.17.camel@josep/
Also on:    postgresql.org/message-id/1120478457.3506.17.camel@josep

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josep.sanmarti@openwired.net
  Subject: Re: select values from interval
  In-Reply-To: <1120478457.3506.17.camel@josep>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox