Re: Bug, feature, quirk? HELP

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Stoppel, Brett W" <bstoppel(at)ku(dot)edu>
Cc: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Bug, feature, quirk? HELP
Date: 2001-04-15 13:48:29
Message-ID: 28553.987342509@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Stoppel, Brett W" <bstoppel(at)ku(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Justin Clift 2001-04-15 14:33:41 erServer beta
Previous Message Len Morgan 2001-04-15 13:43:02 Re: Bug, feature, quirk? HELP