Re: How to join several selects

From: Rod Taylor <pg(at)rbt(dot)ca>
To: Josep Sanmartí <josep(dot)sanmarti(at)openwired(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to join several selects
Date: 2005-08-24 13:52:04
Message-ID: 1124891524.36010.64.camel@home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 2005-08-24 at 15:46 +0200, Josep Sanmartí wrote:
> Hello,
> I have a 'big' problem:
> I have the following table users(name, start_time, end_time), a new row
> is set whenever a user logs into a server. I want to know how many
> users have logged in EVERYDAY between 2 different dates. The only idea
> that I have is making several select (one for each day):
> SELECT COUNT(name) FROM users WHERE start_time between "startDate"
> and "startDate+1"
> SELECT COUNT(name) FROM users WHERE start_time between "startDate+1"
> and "startDate+2"

You have columns named "startDate+2" or are you adding 2 days to a
column named "startDate"?

--

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Sean Davis 2005-08-24 14:03:26 Re: How to join several selects
Previous Message Josep Sanmartí 2005-08-24 13:46:09 How to join several selects