X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0AFAAD701F for ; Wed, 24 Aug 2005 10:57:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01604-09 for ; Wed, 24 Aug 2005 13:57:06 +0000 (GMT) Received: from twiddle.look.ca (beta1.look.ca [207.136.80.125]) by svr1.postgresql.org (Postfix) with ESMTP id E4C74D7071 for ; Wed, 24 Aug 2005 10:57:05 -0300 (ADT) Received: from 209-161-192-161.dsl.look.ca ([209.161.192.161]) by twiddle.look.ca with esmtp (Exim 4.20) id 1E7vkZ-0003LW-UQ; Wed, 24 Aug 2005 13:57:08 +0000 From: Rod Taylor To: Josep =?ISO-8859-1?Q?Sanmart=ED?= Cc: pgsql-sql@postgresql.org In-Reply-To: <430C7A21.9020306@openwired.net> References: <430C7A21.9020306@openwired.net> Date: Wed, 24 Aug 2005 09:52:04 -0400 Message-Id: <1124891524.36010.64.camel@home> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 FreeBSD GNOME Team Port X-SA-Exim-Mail-From: pg@rbt.ca Subject: Re: How to join several selects Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Version: 3.1 (built Tue Feb 24 05:09:27 GMT 2004) X-SA-Exim-Scanned: Yes X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.042 required=5 tests=[AWL=-0.008, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200508/226 X-Sequence-Number: 22454 On Wed, 2005-08-24 at 15:46 +0200, Josep Sanmart=ED wrote: > Hello, > I have a 'big' problem: > I have the following table users(name, start_time, end_time), a new row=20 > is set whenever a user logs into a server. I want to know how many=20 > users have logged in EVERYDAY between 2 different dates. The only idea=20 > that I have is making several select (one for each day): > SELECT COUNT(name) FROM users WHERE start_time between "startDate"=20 > and "startDate+1" > SELECT COUNT(name) FROM users WHERE start_time between "startDate+1"=20 > and "startDate+2" You have columns named "startDate+2" or are you adding 2 days to a column named "startDate"? --=20