Re: select distinct w/order by

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: select distinct w/order by
Дата
Msg-id 200403312137.19552.dev@archonet.com
обсуждение исходный текст
Ответ на select distinct w/order by  ("John Liu" <johnl@emrx.com>)
Ответы Re: select distinct w/order by  ("John Liu" <johnl@stihealthcare.com>)
Список pgsql-general
On Wednesday 31 March 2004 18:50, John Liu wrote:
> I know this is an old topic, but it's not easy to find a way around it, so
> when we migrate SQL from other database to PostgreSQL, it causes a huge
> headache. Here's an extremely simple example -
>
> The original simple SQL -
> select distinct atcode from TMP order by torder;

Can you explain what this means? If I have

atcode | torder
AAA    | 20
BBB    |  5
CCC    | 10
BBB    | 45
CCC    | 27

What order should we get?
You could argue for:
1. BBB,CCC,AAA since that is the order of the min(torder)
2. AAA,CCC,BBB since that is the order of the max(torder)
3. AAA,BBB,CCC if you take the first(torder) you find reading down the page
4. AAA,CCC,BBB if you take the first(torder) but read up the page

Which one should PG pick, and how should it know?

Which one did the other database pick, and why was it right to do so?

--
  Richard Huxton
  Archonet Ltd

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

Предыдущее
От: "Dann Corbit"
Дата:
Сообщение: Re: Wich hardware suits best for large full-text indexed databases
Следующее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: [pgsql-advocacy] Best open source db poll currently