Re: ranked subqueries vs distinct question

Поиск
Список
Период
Сортировка
От Karsten Hilbert
Тема Re: ranked subqueries vs distinct question
Дата
Msg-id 20080514154602.GT4401@merkur.hilbert.loc
обсуждение исходный текст
Ответ на Re: ranked subqueries vs distinct question  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-general
On Wed, May 14, 2008 at 08:21:00AM -0700, Stephan Szabo wrote:

> Can't you just do something like order by name, rank as part of the
> distinct on subselect to force it to pick the rank 1 row for a given name?
>
> So, basically
> select * from
>  ( select distinct on ... order by name, rank )
> order by rank, name;

OK, ordering twice, ..., once to bubble up by rank so the
distinct on picks the rank 1 sub-results ..., second to time
get the final order by name within the ranks. Sounds like an
idea I didn't think of. Will try that. Thanks for the
suggestion !

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

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

Предыдущее
От: Robert Treat
Дата:
Сообщение: Re: Alias in the HAVING clause
Следующее
От: Justin
Дата:
Сообщение: Re: rounding problems