Re: DISTINCT ... ORDER BY

Поиск
Список
Период
Сортировка
От Nabil Sayegh
Тема Re: DISTINCT ... ORDER BY
Дата
Msg-id 3FA92D67.4000200@e-trolley.de
обсуждение исходный текст
Ответ на Re: DISTINCT ... ORDER BY  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Ответы Re: DISTINCT ... ORDER BY  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-novice
Stephan Szabo wrote:

>>should return:
>>
>>myDistinctOrderedCol
>>--------------------
>>a
>>c
>>b
>>
>>The problem is that DISTINCT complains about ORDER BY entries not being in the target list.
>
>
> Right, because given this data:
> col1 | col2
>  a   |  b
>  b   |  c
>  b   |  a
>
> what ordering should
>  select distinct col1 from tab order by col2
> give you?

I want it to just return 1 column ;)

> Does it put b first because there's a col2 with a, or b second because
> there's a col2 with b or is it indeterminate?

It shall not mention col2 at all.
The idea is to
1. ORDER BY expressions
2. Pick only 1 column
3. make this column distinct without losing the sort order

> Maybe something of this general form would work if you want to order by
> the minimums:
> select col3 from tablename group by col3 order by min(col1), min(col2),
> col3, min(col4);

Good idea.
But it would require me to introduce row numbers.
What now ?

TFYH
--
  e-Trolley Sayegh & John, Nabil Sayegh
  Tel.: 0700 etrolley /// 0700 38765539
  Fax.: +49 69 8299381-8
  PGP : http://www.e-trolley.de


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

Предыдущее
От: Nabil Sayegh
Дата:
Сообщение: Re: DISTINCT ... ORDER BY
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: DISTINCT ... ORDER BY