Just add or null
to the count expression
count(e.emp_pf_acc_number like 'T%' or null) as tcnt,
count(e.emp_pf_acc_number like 'N%' or null) as ncnt
count
counts not nulls. As your original expression returns either true
or false
it would always be counted. false or null
evaluates to null
so it is not counted.
There is an optimization to the where
clause
and exists (
select 1
from pfmast_dist
where m.institution_dist = dist_name
)