Re: SQL problem..

From: "Postgres User" <postgres(dot)developer(at)gmail(dot)com>
To: Bauhaus <niemandhier(at)pandora(dot)be>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL problem..
Date: 2007-06-30 21:18:56
Message-ID: b88c3460706301418u9491985l962fb29464fc3b02@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Your query won't work because there is no single Price associated with
a range of dates. It doesn't make sense.

Do you mean to select AVG(Price)?

On 6/28/07, Bauhaus <niemandhier(at)pandora(dot)be> wrote:
> Hello,
>
> I'm an Access/SQL novice and I have an sql problem:
>
> I have the following table Price:
>
> FuelID PriceDate Price
> LPG 1/05/2007 0,2
> LPG 13/05/2007 0,21
> SPS 2/05/2007 1,1
> SPS 15/05/2007 1,08
>
> And I have to make the following query:
>
> FuelID PriceDate_from PriceDate_To Price
> LPG 1/05/2007 13/05/2007 0,2
> SPS 2/05/2007 15/05/2007 1,1
> LPG 13/05/2007 0,21
> SPS 15/05/2007 1,08
>
> I tried this:
>
> SELECT FuelID, min(FuelDate) AS Pricedate_from, max(FuelDate) AS
> PriceDate_to FROM Price GROUP BY FuelID;
>
> Problem is, when I put Price in the select, I get the error 'Price not part
> of an aggregate function' :s
> Eitherway, it doesnt work, I only have one FuelDate_from and one FuelDate_to
> if I use min & max. While there should be several from...to... dates for a
> particular fuel.
>
> How can I solve this ?
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org/
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Wiebe Cazemier 2007-06-30 21:24:41 Re: Do Postgres exceptions rise up the stack?
Previous Message Postgres User 2007-06-30 21:14:18 Do Postgres exceptions rise up the stack?