Re: Couple simple(?) questions...

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Couple simple(?) questions...
Дата
Msg-id 28029.975211762@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Couple simple(?) questions...  (Dmitri Touretsky <dmitri@listsoft.ru>)
Список pgsql-novice
Dmitri Touretsky <dmitri@listsoft.ru> writes:
> 2. There is a table of the following structure:
>    CREATE TABLE test (
>      id       int4,
>      string1  text,
>      string2  text,
>      ord    int2);

>    I need to get a list of different "string1" strings ordered by
>    "ord". But SELECT DISTINCT id, string1 ... ORDER BY ord" doesn't
>    work. Is there any way to get it?

That doesn't seem very well defined.  Your SELECT DISTINCT implies
that there may be multiple entries with the same string1 value, but
perhaps different ord values.  Which ord value are you expecting that
string1 value to be sorted by?

Most likely you'll find that you need to do the SELECT DISTINCT into
a temp table, and then SELECT from the temp table with the desired
output ordering.  In 7.1 it'll be possible to do this in a single
query using subselect-in-FROM, but in 7.0 that feature isn't there.

            regards, tom lane

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

Предыдущее
От: GH
Дата:
Сообщение: Re: Couple simple(?) questions...
Следующее
От: "Mitch Vincent"
Дата:
Сообщение: Re: [HACKERS] Re: Re: re : PHP and persistent connections