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
Pokud chcete, můžete také použít RegEx.
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
Pokud chcete, můžete také použít RegEx.