Re: Find min year and min value

From: Richard Huxton <dev(at)archonet(dot)com>
To: Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Find min year and min value
Date: 2007-10-02 13:40:11
Message-ID: 47024A3B.60909@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2007-10-02 13:45:54 Re: Execution plan caching
Previous Message Stefan Schwarzer 2007-10-02 13:26:17 Find min year and min value