select Name,
count(*) as CountAll,
count(case when Text like 'a1-%' or Text like 'a2-%' or Text like 'a3-%' then 1 end) as CountA1A2A3
from MyTable
group by Name
Anda juga dapat menggunakan RegEx jika diinginkan.
select Name,
count(*) as CountAll,
count(case when Text like 'a1-%' or Text like 'a2-%' or Text like 'a3-%' then 1 end) as CountA1A2A3
from MyTable
group by Name
Anda juga dapat menggunakan RegEx jika diinginkan.