Re: oracle's first_value function for postgres?

Поиск
Список
Период
Сортировка
От Ron Mayer
Тема Re: oracle's first_value function for postgres?
Дата
Msg-id 4329B747.8050702@cheapcomplexdevices.com
обсуждение исходный текст
Ответ на Re: oracle's first_value function for postgres?  (Martijn van Oosterhout <kleptog@svana.org>)
Список pgsql-general
Martijn van Oosterhout wrote:
> On Tue, Sep 13, 2005 at 12:15:21PM -0700, Ben wrote:
>
>>Oracle has a very handy function called first_value, which can be used
>>to turn a set like this:
>
>
> Look at DISTINCT ON ()
>
>
>>Does postgres have something equivalent, or, even better, is there a
>>reasonable way to express this in standard SQL?
>
>
> In standard SQL, not really, which is why it's an extention...

No?    It seems this is similar

SELECT a,b
FROM ( SELECT a,b,
    RANK() OVER (
        PARTITION BY a
        ORDER BY b
    ) rank
    FROM my_table )
WHERE rank = 1
ORDER BY a, rank DESC;

which I think is standard sql-99 with the sql-99 olap extention.

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

Предыдущее
От: Bart McFarling
Дата:
Сообщение: Deadlock
Следующее
От: Андрей
Дата:
Сообщение: How to check is the table system