Re: distinct

Поиск
Список
Период
Сортировка
От John McKown
Тема Re: distinct
Дата
Msg-id Pine.LNX.4.21.0010091903240.28048-100000@linux2.johnmckown.net
обсуждение исходный текст
Ответ на distinct  ("Otwell, Andrew (ISSAtlanta)" <AOtwell@iss.net>)
Список pgsql-general
On Tue, 3 Oct 2000, Otwell, Andrew (ISSAtlanta) wrote:

> I have attempted to run
> select distinct col1 from tablename;
> and it runs fine.
>
> When I run it in a real world environment:
> select distinct col1, col2, col3, col4 from tablename order by col1 desc,
> col2;
> It returns all the values from col1 which appears to be the same thing as
> not using distinct at all.
>
> Am I missing something? I'd like only distinct values on col1 and then I'll
> sort, include, or exclude the other columns.

The DISTINCT keyword means that the row returned (all values
considered together) is
DISTINCT. Not just that the first variable is DISTINCT. So a row having
values of 'a','b' and another row with 'a','c' are distinctly different in
that the second variable is not the same. I don't know of a way to say
that you want "col1" to be distinct. In the above case, which row should
be returned? I.e. if there are two different values for col2, which single
one is returned? random? lowest value?


I hope this makes sense, but I fear that I didn't do a good job of
explaining.

John


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

Предыдущее
От: 100.179370@germanynet.de (Martin Jacobs)
Дата:
Сообщение: Regression tests of plain 7.0.2 fails
Следующее
От: "Mathew Chandy"
Дата:
Сообщение: problems in compiling