Query to Identify Sets Having Given Pattern
644850Jun 16 2008 — edited Jun 16 2008Hi,
Assume that i have following table
Id Code
1 aaa
1 bbb
1 ccc
2 aaa
2 bbb
2 ddd
3 bbb
3 eee
The records will be grouped by Id. I want to identify sets having following criteria
1. Set should have at least one record with code like 'a%'
and should have at least one record for codes 'bbb', 'ccc' (in this case group 1 would be selected)
2. Set should have at least one record with code like 'a%'
and should have at least one record for either 'bbb' or 'ccc' (in this case group 1and 2 would be selected)
Does anyone have idea about how this could be achieved efficiently? Any pointers, references would be appreciated
Regards
~Pravin.