Re: Find min year and min value - Mailing list pgsql-general

From Richard Huxton
Subject Re: Find min year and min value
Date
Msg-id 47024A3B.60909@archonet.com
Whole thread Raw
In response to Find min year and min value  (Stefan Schwarzer <stefan.schwarzer@grid.unep.ch>)
Responses Re: Find min year and min value
List pgsql-general
Stefan Schwarzer wrote:
> Hi there,
>
> I am trying to find in a table with different variables, countries and
> years the
>
>     lowest year
>
> and within that year the
>
>     lowest value
>
>
> The following SELECT works, but I wonder if it is "elegant". Can you
> recommend any other solution?

SELECT value AS minv FROM public_on_table.data
WHERE id_variable = 1
ORDER BY year, value LIMIT 1


--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Stefan Schwarzer
Date:
Subject: Find min year and min value
Next
From: Richard Huxton
Date:
Subject: Re: Execution plan caching