Re: [SQL] SQL confusion

2004-10-12 Thread Thomas F . O'Connell
This is untested, but it might be enough to get you started: SELECT namecounter FROM name n WHERE NOT EXISTS ( SELECT 1 FROM name WHERE hh > 0 AND famnu = n.famnu ) GROUP BY famnu HAVING birthdate = min( birthdate ); What I'm trying to do here is grab all families th

Re: [SQL] SQL confusion

2004-10-09 Thread Michael Fuhr
On Sat, Oct 09, 2004 at 01:39:45PM -0700, Andrew Ward wrote: > > CREATE TABLE name ( > namecounter integer NOT NULL, > firstmiddle character varying(64) NOT NULL, > lastname character varying(64) NOT NULL, > birthdate date, > hh smallint, > famnu integer, > ); > > Each row

Re: [SQL] SQL confusion

2004-10-09 Thread Richard Poole
On Sat, Oct 09, 2004 at 01:39:45PM -0700, Andrew Ward wrote: > > I'm running postgres 7.3.2 on linux, and making my > requests from Perl scripts using DBD::Pg. My table > structure is as follows (irrelevant cols removed) > > CREATE TABLE name ( > namecounter integer NOT NULL, > firstmidd

[SQL] SQL confusion

2004-10-09 Thread Andrew Ward
I'm trying to figure out how to do a particular query, and I'm beating my head against a wall. Here's my situation: I'm running postgres 7.3.2 on linux, and making my requests from Perl scripts using DBD::Pg. My table structure is as follows (irrelevant cols removed) CREATE TABLE name ( nam