Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 26C644760C5 for ; Wed, 28 Aug 2002 17:25:18 -0400 (EDT) Received: from l2.socialecology.com (unknown [4.42.179.131]) by postgresql.org (Postfix) with ESMTP id A708B475EB1 for ; Wed, 28 Aug 2002 17:25:17 -0400 (EDT) Received: from 4.42.179.151 (broccoli.socialecology.com [4.42.179.151]) by l2.socialecology.com (Postfix) with SMTP id BCDF2176F4D for ; Wed, 28 Aug 2002 14:25:18 -0700 (PDT) X-Mailer: UserLand Frontier 8.0.5 (Macintosh OS) (mailServer v1.1..142) Mime-Version: 1.0 Message-Id: <6734364.1181577779@[4.42.179.151]> X-authenticated-sender: erics In-reply-to: <20020828161241.50a8512d.gry@ll.mit.edu> Date: Wed, 28 Aug 2002 14:25:17 -0700 To: pgsql-sql@postgresql.org From: eric soroos Subject: Re: select question Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/407 X-Sequence-Number: 9253 On Wed, 28 Aug 2002 16:12:41 -0400 in message <20020828161241.50a8512d.gry@ll.mit.edu>, george young wrote: > [postgreql 7.2, linux] > I have a table T with columns run, wafer, and test: > T(run text, wafer int, test text) > Given a run and a set of wafers, I need the set of tests that match > *all* the specified wafers: > > run wafer test > a 1 foo > a 2 foo > a 3 foo > a 3 bar > > E.g. > Given run 'a' and wafers (1,3) I should get one row: foo, since only foo matches both 1 and 3. > Given run 'a' and wafers (3) I should get two rows: foo,bar, since both foo and bar match 3. > > Is there some neat way to do this in a single query? > select test from T where run='a' and wafers in ('1','3') group by test eric