Re: [SQL] SQL dealing with subquery

2008-01-16 Thread Bryan Emrys
Following up my treaty rate thoughts, if I'm trying to get the lowest treaty payee (and rate) from a specific list of payees for every possible payor country, the following seems to work, but is it right? I'm specifically wondering about the group by clauses. (Or if there is a better way.) [table t

Re: [SQL] SQL dealing with subquery

2008-01-16 Thread Bryan Emrys
Thanks. It throws off a few extra countries where there is only one treaty, but those are few enough that I can handle them manually. I thought the solution was also going to give me insight into how to select just the lowest rate from each couple, (i.e. for each payor, who is the lowest rate

Re: [SQL] SQL dealing with subquery

2008-01-15 Thread Rodrigo E. De León Plicet
On Jan 15, 2008 1:04 PM, Bryan Emrys <[EMAIL PROTECTED]> wrote: > In other words, in the sample above, I only want to return: > 'Canada','Ireland',0 > 'Canada','Netherlands',5 Try (untested): SELECT t2.* FROM (SELECT payor FROM treaty_rates WHEREpayee IN ('Netherlands'

[SQL] SQL dealing with subquery comparison

2008-01-15 Thread Bryan Emrys
Hi all, I'm having a conceptual problem with a subquery here - any help would be appreciated. I have a table treaty_rates with columns payor, payee, rate where payor and payee are countries. Sample set: 'US','UK',5 'US','Ireland',5 'US','Netherlands',5 'US','China',10 'Canada','US',0 'Canada','Ire

[SQL] SQL dealing with subquery

2008-01-15 Thread Bryan Emrys
Hi all, I'm having a conceptual problem with a subquery here - any help would be appreciated. I have a table treaty_rates with columns payor, payee, rate where payor and payee are countries. Sample set: 'US','UK',5 'US','Ireland',5 'US','Netherlands',5 'US','China',10 'Canada','US',0 'Canada','Ire