From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andreas Joseph Krogh <andreak@officenet.no>
Cc: pgsql-sql@postgresql.org
Subject: Re: Problems with distinct
Date: Mon, 13 Feb 2006 14:22:00 -0500
Message-ID: <3717.1139858520@sss.pgh.pa.us> (raw)
In-Reply-To: <200602132019.30393.andreak@officenet.no>
References: <200602132019.30393.andreak@officenet.no>
Andreas Joseph Krogh <andreak@officenet.no> writes:
> 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 not a function, it's a modifier attached to SELECT. The
parentheses in your first example are a no-op.
regards, tom lane
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: tgl@sss.pgh.pa.us, andreak@officenet.no
Subject: Re: Problems with distinct
In-Reply-To: <3717.1139858520@sss.pgh.pa.us>
* 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