Re: group by before and after date

From: PFC <lists(at)boutiquenumerique(dot)com>
To: "Sim Zacks" <sim(at)compulab(dot)co(dot)il>, pgsql-sql(at)postgresql(dot)org
Subject: Re: group by before and after date
Date: 2005-03-14 08:58:10
Message-ID: opsnmdu8cuth1vuj@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


> 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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message PFC 2005-03-14 09:02:08 Re: Newbie wonder...
Previous Message Ragnar Hafstað 2005-03-14 08:46:33 Re: How to cast VARCHAR to BYTEA and vice-versa?