Re: PostgreSQL bug in SELECT DISTINCT - Mailing list pgsql-bugs

From Tom Lane
Subject Re: PostgreSQL bug in SELECT DISTINCT
Date
Msg-id 24905.988903570@sss.pgh.pa.us
Whole thread Raw
In response to PostgreSQL bug in SELECT DISTINCT  ("J.R. Onyschak" <jonyschak@nvisia.com>)
List 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

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: freebsd sample startup script doesn't work
Next
From: Peter Eisentraut
Date:
Subject: Re: SELECT min(id) FROM test; uses seqscan