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
Du kan også bruge et RegEx, hvis du ønsker det.
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
Du kan også bruge et RegEx, hvis du ønsker det.