Filtering "under" is a wrong approach because it remove information about not "under".
I would attack the problem with 2 cascading selects.
The first do a synthesis of database:
field CASEID
field records: count(CASEID)
field unders: sum(if(TYPE="UNDER", 1, 0))
select CASEID, count(CASEID) as records, sum(if(TYPE="UNDER", 1, 0)) as unders GROUP BY CASEID
caseid records unders
A1 2 2
B1 3 1
C1 2 0
D1 1 1
E1 2 1
In the second, you compare records and unders to know which caseid to keep according to your needs.
Left as exercise.