The first step to gathering this information is getting the list of groups whose members we want to query. Consider the following group setup:
Group Name Parent Group
------------------- -------------------
Leadership Givers
Gold Givers Leadership Givers
Silver Givers Leadership Givers
Bronze Givers Leadership Givers
Volunteers
Day of Caring Vol Volunteers
It would be easy if groups weren't hierarchical, but they are so we must account for this. For instance, if we do a query and request members of the "Leadership Givers" group, what we are really saying is that we want members of that group PLUS members of the Gold, Silver and Bronze groups. To do this, we need a query to get the list of groups that we are interested in:
select groupid
from camgroups
connect by prior groupid = parentgroupid
start with groupdesc = 'Leadership Givers'
Next, we combine this information with the group membership list to get all members of a group:
select distinct nameid
from camgroupmembers
where groupid in (
select groupid
from camgroups
connect by prior groupid = parentgroupid
start with groupdesc = 'Leadership Givers')
To combine this with other useful information, such as the giver's name and address, we use one of our standard views:
with groupmembers as
(select distinct nameid
from camgroupmembers
where groupid in (
select groupid
from camgroups
connect by prior groupid = parentgroupid
start with groupdesc = 'Leadership Givers'))
select displayname, addressline1, addressline2, city, state, zip
from camnamesv n, groupmembers g
where n.nameid = g.nameid