Find min year and min value

Поиск
Список
Период
Сортировка
От Stefan Schwarzer
Тема Find min year and min value
Дата
Msg-id F4D18345-B3E4-407C-983D-0DB79F981012@grid.unep.ch
обсуждение исходный текст
Ответы Re: Find min year and min value
Список pgsql-general
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
            MIN(value) AS minv
    FROM
            public_one_table.data
    WHERE
            year =
            (
                SELECT
                        MIN(year) AS min_year
                FROM
                        public_one_table.data
                WHERE
                        id_variable = 1
            ) AND
            id_variable = 1



Thanks for any help!

Stef

В списке pgsql-general по дате отправления:

Предыдущее
От: "Philippe Lang"
Дата:
Сообщение: Execution plan caching
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Find min year and min value