pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Stuart Rison <rison@biochemistry.ucl.ac.uk>
Cc: pgsql-sql <pgsql-sql@postgreSQL.org>
Subject: Re: [SQL] self-join and DISTINCT quandry.
Date: Wed, 29 Sep 1999 19:22:29 -0400
Message-ID: <5276.938647349@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.10.9909292106040.30104-100000@bsmlx17>

Stuart Rison <rison@biochemistry.ucl.ac.uk> writes:
> But what is I didn't want the information to appear twice.  I could try
> adding DISTINCT but that would not work because row a,1,7 is of course
> DISTINCT from a,7,1 although I am looking for such duplication to be
> eliminated...

Bit of a hack, but you could add the condition
	... AND t1.number < t2.number;
to get rid of the two-way duplication that otherwise arises from
your join.  (Any other way of selecting just one of the pair
of matches would work as well, of course; you could compare the
two row's OIDs if nothing else was handy.)

Not sure if you still need DISTINCT after that.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <5276.938647349@sss.pgh.pa.us>
Permalink:  ../5276.938647349@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5276.938647349@sss.pgh.pa.us

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, rison@biochemistry.ucl.ac.uk
  Subject: Re: [SQL] self-join and DISTINCT quandry.
  In-Reply-To: <5276.938647349@sss.pgh.pa.us>
  References: <Pine.LNX.4.10.9909292106040.30104-100000@bsmlx17> <5276.938647349@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