Re: Search for lists - Mailing list pgsql-general

From Daron Ryan
Subject Re: Search for lists
Date
Msg-id 4DFD844F.2030901@gmail.com
Whole thread Raw
In response to Re: Search for lists  (David Johnston <polobo@yahoo.com>)
List pgsql-general
Thanks.
On 19/06/2011 8:09 AM, David Johnston wrote:
> An alternative approach would be to select using a IN condition on the where clause and group by column 1 and column
2. Then, using this as a sub-select group by the resultant column 1 and a count on column two.  The matching
identifiersare those with a count equal to the number of entries in the original IN condition. 
>
> Basically count how many of values each distinct key in column 1 matches and keep those keys where the count and the
numberof values match. 
>
> David J.
>
>
> On Jun 18, 2011, at 17:51, Daron Ryan<daron.ryan@gmail.com>  wrote:
>
>> Hello,
>>
>> I need to search a table to find sets of rows that have a column matching itself for the whole set and another
columnmatching row for row with a list I am going to supply. The result I should receive should be value of the column
thatmatches itself. 
>>
>> For example given the following data in my table:
>>
>> 3;         1
>> 3;         2
>> 4;         8
>> 4;         9
>> 4;         10
>>
>> I might need to search for 1,2. This should produce the result 3. Or if I were to search for 8, 9, 10 the result
shouldbe 4. Searching for 8, 9 should produce an empty result as should 8, 9, 10, 11. 
>>
>> Can anyone recommend a strategy?
>>
>> --
>> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-general


pgsql-general by date:

Previous
From: David Johnston
Date:
Subject: Re: Referencing function value inside CASE..WHEN
Next
From: David Boreham
Date:
Subject: Re: Another RAID controller recommendation question