Re: Why must SELECT DISTINCT, ORDER BY expressions must appear in target list?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dave Smith <dave(dot)smith(at)candata(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Why must SELECT DISTINCT, ORDER BY expressions must appear in target list?
Date: 2003-02-10 19:36:07
Message-ID: 16190.1044905767@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dave Smith <dave(dot)smith(at)candata(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Bearer 2003-02-10 19:42:15 Oracle9i's list partitioning equivalent feature
Previous Message Ed L. 2003-02-10 19:31:54 Re: 7.3.2: test select_having ... FAILED