Re: PostgreSQL bug in SELECT DISTINCT

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: "J.R. Onyschak" <jonyschak@nvisia.com>
Cc: pgsql-bugs@postgresql.org
Date: 2001-05-03T15:26:10Z
Lists: pgsql-bugs
"J.R. Onyschak" <jonyschak@nvisia.com> writes:
> When I execute the following query:
> SELECT DISTINCT title FROM division ORDER BY UPPER(title);

> I get:
> ERROR:  For SELECT DISTINCT, ORDER BY expressions must appear in target list

> If I remove DISTINCT, the query works fine.

> Is this illegal or a known bug?

This is not a bug, but an intentional restriction to prevent ill-defined
query results.  Why don't you just "ORDER BY title"?

			regards, tom lane