SQL dealing with subquery - Mailing list pgsql-sql

From Bryan Emrys
Subject SQL dealing with subquery
Date
Msg-id eee4647d0801151004t288b0819ocbc0cae8e0df7f24@mail.gmail.com
Whole thread Raw
Responses Re: SQL dealing with subquery  ("Rodrigo E. De León Plicet" <rdeleonp@gmail.com>)
List pgsql-sql
Hi all,<br />I'm having a conceptual problem with a subquery here - any help would be appreciated.<br /><br />I have a
tabletreaty_rates with columns payor, payee, rate where payor and payee are countries.<br />Sample set: <br />
'US','UK',5<br/>'US','Ireland',5<br />'US','Netherlands',5<br />'US','China',10<br />'Canada','US',0<br
/>'Canada','Ireland',0<br/>'Canada','Netherlands',5 <br />'Canada','UK,5<br />'Belgium','Netherlands',0<br /><br
/>Thereis no certainty  that the same payees exist for each payor (i.e. not all countries have treaties with other all
othercountries)<br /><br />I want to select all rows where the payee is in some array (e.g, in
('Netherlands','Ireland'))and the rate is not the same<br /><br />In other words, in the sample above, I only want to
return:<br/>'Canada','Ireland',0 <br />'Canada','Netherlands',5<br /><br />The initial query to limit the rows to the
specifiedpayees is obvious, but I can't get my mind around how to compare each set of rows where the payor is the same
country.Running select payor, payee, rate where payee in ('Netherlands','Ireland') will return 132 rows (66 pairs). <br
/><br/>Any suggestions on how to compare the pairs would be appreciated. <br /><br />Bryan<br /> 

pgsql-sql by date:

Previous
From: John Hasler
Date:
Subject: Re: UTF8 encoding and non-text data types
Next
From: "Bryan Emrys"
Date:
Subject: SQL dealing with subquery comparison