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;