pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joshua Tolley <eggyknap@gmail.com>
To: Frank Bax <fbax@sympatico.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: join returns too many results...
Date: Mon, 4 Oct 2010 07:24:39 -0600
Message-ID: <4ca9d59a.26798e0a.1059.25cf@mx.google.com> (raw)
In-Reply-To: <BLU0-SMTP934181715239A633CC970AAC6B0@phx.gbl>
References: <BLU0-SMTP934181715239A633CC970AAC6B0@phx.gbl>

On Sun, Oct 03, 2010 at 02:54:41PM -0400, Frank Bax wrote:
> Whatever clause I choose to add I *must* ensure that final result set  
> contains only one-to-one join between tables.  Either of these two  
> results is acceptable:
>
> For option 1; result C=All or C=Centre is acceptable.
> For option 2; result B=NE70 or B=NE75 or B=NE80 is acceptable.
>
> I am lost trying to construct SQL to accomplish this...

Try DISTINCT ON, after ensuring the results are ordered meaningfully.

http://www.postgresql.org/docs/current/interactive/sql-select.html#SQL-DISTINCT

--
Joshua Tolley / eggyknap
End Point Corporation
http://www.endpoint.com

Attachments:

  [application/pgp-signature] signature.asc (196B, ../4ca9d59a.26798e0a.1059.25cf@mx.google.com/2-signature.asc)
  download

view thread (2+ messages)

Message-ID: <4ca9d59a.26798e0a.1059.25cf@mx.google.com>
Permalink:  ../4ca9d59a.26798e0a.1059.25cf@mx.google.com/
Also on:    postgresql.org/message-id/4ca9d59a.26798e0a.1059.25cf@mx.google.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: eggyknap@gmail.com, fbax@sympatico.ca
  Subject: Re: join returns too many results...
  In-Reply-To: <4ca9d59a.26798e0a.1059.25cf@mx.google.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