From: PFC <lists@boutiquenumerique.com>
To: Sim Zacks <sim@compulab.co.il>
To: pgsql-sql@postgresql.org
Subject: Re: group by before and after date
Date: Mon, 14 Mar 2005 09:58:10 +0100
Message-ID: <opsnmdu8cuth1vuj@localhost> (raw)
In-Reply-To: <d0jkcf$28sb$1@news.hub.org>
References: <d0jkcf$28sb$1@news.hub.org>
> I have 2 tables 1 has a date field and component need by that date and
> the
> other has all the upcoming orders.
> I am trying to build a query that will give me the Date and ComponentNeed
> and also how many components have been ordered before that date and how
> many
> after.
> PostGreSQL is telling me I need to group on DatePromisedBy. I have tried
> a
> number of different possibilities which haven't worked and now I have run
> into brain freeze. Any help would be appreciated.
You could :
SELECT ..., sum( stuff ), ..., (DatePromisedBy > a_particular_date) as
after GROUP BY after
You'll get two lines, one the sum of things before a_particular_date,
one of things after a_particular_date. Look in the 'after' field to know
which is which.
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: lists@boutiquenumerique.com, sim@compulab.co.il
Subject: Re: group by before and after date
In-Reply-To: <opsnmdu8cuth1vuj@localhost>
* 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