Re: [SQL] Best way to "and" from a one-to-many joined table?

2008-12-05 Thread Oliveiros Cristina
Hello, Bryce. It wasn't supposed to output duplicates. I have assumed that on the test_attributes u didn't have duplicate records, i.e., you didn't have the same pair (people_id, attribute) more than once... But it seems you do... And Hence the duplicate row for Obama . Why is that? One person can

Re: [SQL] Best way to "and" from a one-to-many joined table?

2008-12-05 Thread Bryce Nesbitt
It works (with a DISTINCT clause added because of the duplicated row for Obama).  It has a nice clean looking explain plan.  It has the slowest execution time on this sample table (though that might not mean anything). SELECT DISTINCT person_name FROM test_people p JOIN test_attributes a ON ((

Re: [SQL] Best way to "and" from a one-to-many joined table?

2008-12-05 Thread Milan Oparnica
Hi, This is how I do it, and it runs fast: select p.* from test_people p inner join test_attributes a on p.people_id = a.people_id where a."attribute" = @firstAttr or a."attribute" = @secondAttr If you have many attributes to search for you can replace the where part with where a."attribut

Re: [SQL] Best way to "and" from a one-to-many joined table?

2008-12-05 Thread Oliveiros Cristina
Howdy, Bryce Could you please try this out and tell me if it gave what you want. Best, Oliveiros SELECT person_name FROM test_people p JOIN test_attributes a ON ((a.people_id = p.people_id) AND (a."attribute" = @firstAttr)) JOIN test_attributes b ON ((b."people_id" = p."people_id") AND (b."attri

Re: [SQL] Aggregates with NaN values

2008-12-05 Thread Sean Davis
On Fri, Dec 5, 2008 at 1:51 PM, Mark Roberts <[EMAIL PROTECTED]> wrote: > > On Thu, 2008-12-04 at 13:01 -0500, Sean Davis wrote: >> I am happy to see NaN and infinity handled in input. I would now like >> to compute aggregates (avg, min, max, etc) on columns with NaN values >> in them. The standa

[SQL] Best way to "and" from a one-to-many joined table?

2008-12-05 Thread Bryce Nesbitt
Dear Experts, I'm looking for a good technique to do "and" searches on one-to-many joined tables.  For example, to find people with both 'dark hair' and 'president': # select * from test_people join test_attributes using (people_id); +---+-+---+ | people_id | p

Re: [SQL] Aggregates with NaN values

2008-12-05 Thread Mark Roberts
On Thu, 2008-12-04 at 13:01 -0500, Sean Davis wrote: > I am happy to see NaN and infinity handled in input. I would now like > to compute aggregates (avg, min, max, etc) on columns with NaN values > in them. The standard behavior (it appears) is to have the aggregate > return NaN if the data con