Re: select question

From: eric soroos <eric-psql(at)soroos(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: select question
Date: 2002-08-28 21:25:17
Message-ID: 6734364.1181577779@[4.42.179.151]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 28 Aug 2002 16:12:41 -0400 in message <20020828161241(dot)50a8512d(dot)gry(at)ll(dot)mit(dot)edu>, george young <gry(at)ll(dot)mit(dot)edu> 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Robert Treat 2002-08-28 23:27:46 Re: [SQL] LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1?
Previous Message Bruce Momjian 2002-08-28 21:06:58 Re: [SQL] LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1?