Re: BUG #1522: there's a syntax error using psql, distinct

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: DIEGO URRA <diegomann(at)yahoo(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1522: there's a syntax error using psql, distinct
Date: 2005-03-04 22:18:09
Message-ID: 20050304140946.A74108@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, 3 Mar 2005, DIEGO URRA wrote:

>
> The following bug has been logged online:
>
> Bug reference: 1522
> Logged by: DIEGO URRA
> Email address: diegomann(at)yahoo(dot)com
> PostgreSQL version: 8.0
> Operating system: REDHAT 6.2
> Description: there's a syntax error using psql, distinct
> Details:
>
> hi!
>
> select distinct(id) from results;
> works fine
>
> select distinct(id) || 'xyz' from results;
> works fine
>
> select 'abc' || distinct(id) || 'xyz' from resuls;
> syntax error
>
> is this a bug? thanks in advance

I don't think so. DISTINCT goes at the front of the select list if used.
I think perhaps you're being mislead by the parens around id in the above
which make it looks as if the distinct is being applied to id in the first
two queries rather than to the full expressions in the select list ( (id)
and (id)|| 'xyz' respectively).

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2005-03-05 04:43:59 Re: BUG #1524: drop view cascade deletes other user's views
Previous Message Theo Petersen 2005-03-04 20:22:13 BUG #1527: select retrieves 0 rows after vacuum analyze