Getting Records Returned When Criteria Doesn't Match (Using One Query)
I have made two queries which I would like to fold into one query if possible. The first query includes all grp_id's. The second query updates grp_id's with an (active) member count. This second query has criteria in it that grabs only grp_id's that have active members. This would be similar to say, for example, a left join situation where everything is returned from table A and only those matching from table B.
The problem is that if I put these together, they have to be linked by grp_id, so obvioulsy, if I put these queries together, the only grp_id's I will get back are the ones that have active members in them, but as I mentioned, I need all grp_id's to be shown regardless of any active membership.
So, here is the code that doesn't work to give a better idea of what I want.
select g00.grp_id,
count(m06.subs_ssn)
from gmaster g00
join m_elig m06 on
g00.grp_id = m06.grp_id
and m06.eff_date < sysdate
and m06.exp_date > sysdate
and m06.stat_code = 'ACTIVE'
group by g00.grp_id
Again, this will only give me counts for grp_id's with active members in them, whereas I want all grp_id's shown and those grp_id's without active members to have a zero next to the count..
m06 gives the member data and g00 gives the grp_id data. The m06 eff_date and exp_date and stat_code as shown above determine active members..
Thanks for any suggestions..