Re: SELECT DISTINCT ... ORDER BY problem

Поиск
Список
Период
Сортировка
От Adam Rich
Тема Re: SELECT DISTINCT ... ORDER BY problem
Дата
Msg-id 121c01c9599d$bcb97ca0$362c75e0$@r@sbcglobal.net
обсуждение исходный текст
Ответ на Re: SELECT DISTINCT ... ORDER BY problem  ("David Rowley" <dgrowley@gmail.com>)
Ответы Re: SELECT DISTINCT ... ORDER BY problem  ("David Rowley" <dgrowley@gmail.com>)
Список pgsql-general
> >
> > When we get windowing functions, a lot of this pain will go away :)
> >
>
> Yes! Hope it won't be too long now. The patch seems to behave like it
> should
> now :)
> Hopefully we'll see it commited for 8.4.
>
> Though this does not look too much cleaner at least it's standard SQL:
>
> A preview for Madi:
>
> SELECT foo,bar
> FROM (SELECT foo,bar,
>              ROW_NUMBER() OVER (PARTITION BY foo ORDER BY bar) AS pos
>       FROM table
> ) AS t
> WHERE pos = 1
> ORDER BY bar;
>
> Probably easier to understand what's going on in this one.
>
> David.
>

Is Oracle's FIRST_VALUE function not a SQL standard?   The way I would
do this in Oracle looks like:

SELECT foo, FIRST_VALUE(bar) OVER (PARTITION BY foo ORDER BY bar) as bar
FROM table

http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions059.
htm








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

Предыдущее
От: "David Rowley"
Дата:
Сообщение: Re: SELECT DISTINCT ... ORDER BY problem
Следующее
От: "中和刘"
Дата:
Сообщение: Re: is there any error for my postgresql installation?