Re: question about a select

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: question about a select
Дата
Msg-id 20031009151156.H74915@megazone.bigpanda.com
обсуждение исходный текст
Ответ на Re: question about a select  (Cindy <ctmoore@uci.edu>)
Список pgsql-general
On Thu, 9 Oct 2003, Cindy wrote:

> Stephan Szabo writes:
>  >On Thu, 9 Oct 2003, Cindy wrote:
>  >> Text=# select distinct on (y_level) y_level, byteloc from
>  >> citations_by_level where aid=543 and wid=1 order by byteloc;
>  >> ERROR:  SELECT DISTINCT ON expressions must match initial ORDER BY
>  >> expressions
>  >
>  >Maybe something like:
>  >
>  >select y_level from (select distinct on (y_level) y_level,
>  >byteloc from citations_by_level where aid=543 and wid=1) tab order by
>  >byteloc;
>
> Hm...this seems to pick out the y_level with the largest byteloc
> associated with it...I need the y_level with the smallest byteloc and
> then sorted by that...lemme play this, but any other suggestions also
> welcomed...

I think an order by y_level, byteloc in the subquery might give you the
ordering you want for the distinct on step, and then the outer order by
will order the y_levels by their respective bytelocs.


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

Предыдущее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: Response from MySql AB (Re: Humor me: Postgresql vs.
Следующее
От: jearl@bullysports.com
Дата:
Сообщение: Re: Response from MySql AB (Re: Humor me: Postgresql vs.