From: | Joshua Tolley <eggyknap(at)gmail(dot)com> |
---|---|
To: | Frank Bax <fbax(at)sympatico(dot)ca> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: join returns too many results... |
Date: | 2010-10-04 13:24:39 |
Message-ID: | 4ca9d59a.26798e0a.1059.25cf@mx.google.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Ozer, Pam | 2010-10-04 15:40:43 | Re: Random sort with distinct |
Previous Message | Scott Marlowe | 2010-10-04 02:46:03 | Re: Need magic for inserting in 2 tables |