From: Owen Jacobson <ojacobson@osl.com>
To: pgsql-sql@postgresql.org
Subject: Re: Problems with distinct
Date: Mon, 13 Feb 2006 11:24:09 -0800
Message-ID: <144D12D7DD4EC04F99241498BB4EEDCC20D48B@nelson.osl.com> (raw)
Andreas Joseph Krogh wrote:
> Any idea why this works:
>
> SELECT distinct(g.groupname), g.id, g.p_id FROM onp_group g,
> onp_group g2
> WHERE g.id IN(SELECT g2.id UNION SELECT group_id FROM
> onp_group_children WHERE
> child_id = g2.id)
> AND g2.id IN(1,2,109,105, 112);
>
> And not this:
>
> SELECT g.id, g.p_id, distinct(g.groupname) FROM onp_group g,
> onp_group g2
> WHERE g.id IN(SELECT g2.id UNION SELECT group_id FROM
> onp_group_children WHERE
> child_id = g2.id)
> AND g2.id IN(1,2,109,105, 112);
Distinct is an SQL keyword, not a function. The former is exactly equivalent to
SELECT DISTINCT g.groupname, g.id, .... FROM ....
except that the first field is inside a (trivial) expression that makes it look like a function call.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ojacobson@osl.com
Subject: Re: Problems with distinct
In-Reply-To: <144D12D7DD4EC04F99241498BB4EEDCC20D48B@nelson.osl.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox