select
' my SQL Output '
, Ownername
, Count(DogName) as NumberOfDogs
, sum(case when Vaccine = 'Yes' then 1 else 0 end ) as DogsWithVaccine
, sum(case when Vaccine = 'No' then 1 else 0 end ) as DogsWithoutVaccine
from
@Starting_Data
group by
Ownername
declare @Starting_Data table (Ownername varchar(200), Dogname varchar(200) , Vaccine varchar(200) )
insert into @Starting_Data Values
('Didi','Bruce ','Yes'),
('Didi','Dan ','No'),
('Didi','Dagi ','Yes'),
('Guy','Mika ','Yes'),
('Guy','Blue ','No')