Hi All
I'd really appreciate your assistance! I have to differentiate between (category 1): grp_id where at least one row for a given grp_id has a cob_ind > spaces and (category 2 grp_id where all rows for a given grp_id has cob_ind = spaces. I'm using count to do this. If count > 0 it fits category 1. If count = 0 it fits category 2.
I'm trying to get a count for each grp_id in TABLE A of how many total rows have cob_ind > ' ' (space). I'm using 2 queries. The first query works fine but the second query returns 0 rows and there are grp_ids in TABLE A where cob_ind for all rows for a particular grp_id = spaces.
After the 2 queries below, I've displayed a dummy table and what the result tables should look like for query 1 and query 2.
------------------
TO GET GRP_IDS where at least one row has a cob_ind value (this works):
<begin sql>
Select grp_id, count(grp_id) as grpcount
from a_iogbxf x
where x.cob_ind > ' '
group by grp_id having grpcount > 0
</end sql>
------------
TO GET GRP_IDS where at all cob_ind = spaces (this does not work):
<begin sql>
Select grp_id, count(grp_id) as grpcount
from a_iogbxf x
where x.cob_ind > ' '
group by grp_id having grpcount = 0
</end sql>
------------
Source TABLE A data:
grp_id cob_ind
0001
0001 444
0002
0002
0003 888
result set query 1
grp_id grpcount
0001 1
0003 1
result set for query 2 should be:
grp_id grpcount
0002 0
Thanks for any and all help! I've been wrestling with this all morning.
I'd really appreciate your assistance! I have to differentiate between (category 1): grp_id where at least one row for a given grp_id has a cob_ind > spaces and (category 2 grp_id where all rows for a given grp_id has cob_ind = spaces. I'm using count to do this. If count > 0 it fits category 1. If count = 0 it fits category 2.
I'm trying to get a count for each grp_id in TABLE A of how many total rows have cob_ind > ' ' (space). I'm using 2 queries. The first query works fine but the second query returns 0 rows and there are grp_ids in TABLE A where cob_ind for all rows for a particular grp_id = spaces.
After the 2 queries below, I've displayed a dummy table and what the result tables should look like for query 1 and query 2.
------------------
TO GET GRP_IDS where at least one row has a cob_ind value (this works):
<begin sql>
Select grp_id, count(grp_id) as grpcount
from a_iogbxf x
where x.cob_ind > ' '
group by grp_id having grpcount > 0
</end sql>
------------
TO GET GRP_IDS where at all cob_ind = spaces (this does not work):
<begin sql>
Select grp_id, count(grp_id) as grpcount
from a_iogbxf x
where x.cob_ind > ' '
group by grp_id having grpcount = 0
</end sql>
------------
Source TABLE A data:
grp_id cob_ind
0001
0001 444
0002
0002
0003 888
result set query 1
grp_id grpcount
0001 1
0003 1
result set for query 2 should be:
grp_id grpcount
0002 0
Thanks for any and all help! I've been wrestling with this all morning.