Re: Select distinct and order by.

Поиск
Список
Период
Сортировка
От Tod McQuillin
Тема Re: Select distinct and order by.
Дата
Msg-id Pine.GSO.4.33.0107170818360.13580-100000@sysadmin
обсуждение исходный текст
Ответ на Select distinct and order by.  (Carlos <carlos@solaria-mediterranea.com>)
Список pgsql-sql
On Wed, 11 Jul 2001, Carlos wrote:

> Select distinct field1, field2 from table1 order by field3;
>
> The value return by PQresultErrorMessage is:
>
> For SELECT DISTINCT, ORDER BY expressions must appear in target list

That's because this query is ambiguous.

What if table1 looks like this:

field1    field2    field3
------    ------    ------
a    b    1
a    b    3
c    d    2

What should your query return then?  Both

a    b
c    d

and

c    d
a    b

are valid, depending on which 'a b' row was chosen.

If 6.5.3 allowed that, it was a mistake to rely on it because the answer
is undefined.
-- 
Tod McQuillin



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

Предыдущее
От: Raymond Chui
Дата:
Сообщение: Why lost all foreign key constraits after cluster?
Следующее
От: "Chris Ruprecht"
Дата:
Сообщение: First steps in plpgsql - language not recognized?