The basic idea is this:declare @t table(country char(2), id char(3), [plan] char(1))insert into @tselect 'DE' , 'XX1' , 'P' union allselect 'US' , 'XX2' , 'W' union allselect 'US' , 'XX3' , 'P' union allselect 'DE' , 'XX4' , 'P'select [plan], sum(case when country='DE' then 1 else 0 end) [DE], sum(case when country='US' then 1 else 0 end) [US]from @tgroup by [plan]
This can be achieved by using PIVOT operator as well. If it needs to be dynamic based on varying 'country' then look into 'Dynamic Pivot' here on sqlteam.