Re: SQL dealing with subquery - Mailing list pgsql-sql

From Bryan Emrys
Subject Re: SQL dealing with subquery
Date
Msg-id eee4647d0801160934n3efe1e28h5a7c1e1cb5edf1ad@mail.gmail.com
Whole thread Raw
In response to Re: SQL dealing with subquery  (Bryan Emrys <bryan.emrys@gmail.com>)
List pgsql-sql
<br />Following up my treaty rate thoughts, if I'm trying to get the lowest treaty payee (and rate) from a specific
listof payees for every possible payor country, the following seems to work, but is it right? I'm specifically
wonderingabout the group by clauses. (Or if there is a better way.) [table treaties has columns payor,payee,rate and in
thissample, I'm just trying to find which country payee between Ireland and the Netherlands has the lowest rate from
eachindividual payor country.] <br /><br />select a.payor,a.payee,a.rate<br />from treaties a,<br /><br />(select
payor,min(rentr)from treaties<br />where payee in ('Ireland','Netherlands') group by payor<br />) b<br /><br />where
a.payor=b.payor<br/>and a.rate = b.min<br />and payee in ('Ireland','Netherlands')<br />group by a.payor, a.payee,
a.rate<br/> 

pgsql-sql by date:

Previous
From: Franklin Haut
Date:
Subject: Re: Update PK Violation
Next
From: Kevin Jenkins
Date:
Subject: How to test/read a stored procedure that returns a boolean?