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
También puede usar un RegEx si lo desea.
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
También puede usar un RegEx si lo desea.
Cómo ver varias consultas y resultados en paralelo en SQL Server Management Studio (SSMS) - Tutorial de SQL Server/TSQL, parte 14
Implementación de un certificado para SQL Server de conexión cifrada
Solución de problemas de los grupos de disponibilidad AlwaysOn de SQL Server
Tablas dinámicas en MySQL