pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rodrigo De León <rdeleonp@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: SQL problem...
Date: Thu, 28 Jun 2007 19:54:36 -0000
Message-ID: <1183060476.696945.312620@q75g2000hsh.googlegroups.com> (raw)
In-Reply-To: <89Tgi.8082$2X.3645@biebel.telenet-ops.be>
References: <89Tgi.8082$2X.3645@biebel.telenet-ops.be>

On Jun 28, 1:43 pm, "Bauhaus" <niemandh...@pandora.be> wrote:
> 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

SELECT   fuelid, pricedate AS pricedate_from
       , (SELECT MIN(pricedate)
            FROM price
           WHERE fuelid = s.fuelid
             AND pricedate > s.pricedate) AS pricedate_to, price
    FROM price s
ORDER BY pricedate_from;




view thread (8+ messages)

Message-ID: <1183060476.696945.312620@q75g2000hsh.googlegroups.com>
Permalink:  ../1183060476.696945.312620@q75g2000hsh.googlegroups.com/
Also on:    postgresql.org/message-id/1183060476.696945.312620@q75g2000hsh.googlegroups.com

 · 

reply

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: rdeleonp@gmail.com
  Subject: Re: SQL problem...
  In-Reply-To: <1183060476.696945.312620@q75g2000hsh.googlegroups.com>

* 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