Re: Why must SELECT DISTINCT, ORDER BY expressions must appear in target list? - Mailing list pgsql-general

From Tom Lane
Subject Re: Why must SELECT DISTINCT, ORDER BY expressions must appear in target list?
Date
Msg-id 16190.1044905767@sss.pgh.pa.us
Whole thread Raw
In response to Why must SELECT DISTINCT, ORDER BY expressions must appear in target list?  (Dave Smith <dave.smith@candata.com>)
List pgsql-general
Dave Smith <dave.smith@candata.com> writes:
> ERROR:  For SELECT DISTINCT, ORDER BY expressions must appear in target
> list

> This seems like a bug.

No, it isn't.  Consider

    SELECT DISTINCT x FROM tab ORDER BY y;

Assuming there are multiple values of y for any given x, how would you
expect the result to be sorted?  It's ill-defined.

            regards, tom lane

pgsql-general by date:

Previous
From: "Ed L."
Date:
Subject: Re: 7.3.2: test select_having ... FAILED
Next
From: Tom Lane
Date:
Subject: Re: 7.3.2: test select_having ... FAILED