Re: Bug, feature, quirk? HELP - Mailing list pgsql-general

From Tom Lane
Subject Re: Bug, feature, quirk? HELP
Date
Msg-id 28553.987342509@sss.pgh.pa.us
Whole thread Raw
In response to Bug, feature, quirk? HELP  ("Stoppel, Brett W" <bstoppel@ku.edu>)
List pgsql-general
"Stoppel, Brett W" <bstoppel@ku.edu> writes:
> I tried the following command
> db=> SELECT DISTINCT name, city FROM table ORDER BY trim(table.name);
> ERROR:  For SELECT DISTINCT, ORDER BY expressions must appear in target list

> Are there work arounds?

What's wrong with doing what the message suggests?
SELECT DISTINCT trim(name), city FROM table ORDER BY trim(name);

> Should I just give up for now (i.e. wait for 7.1+n to come out)?

Don't hold your breath.  The reason for the restriction is that the
results are ambiguous without it --- maybe not terribly ambiguous in
this particular case, but it's easy to create examples where you have
no idea what values are to be used for the sort.  For example
    SELECT DISTINCT foo, bar FROM table ORDER BY baz;

            regards, tom lane

pgsql-general by date:

Previous
From: "Len Morgan"
Date:
Subject: Re: Bug, feature, quirk? HELP
Next
From: "Stan Brown"
Date:
Subject: Recipe management application?