если номер опции ограничен, вы можете попробовать использовать группу, выбрав union all
select brand, count(AA) AA, count(AAA) AAA, count(C) C, count(D) D
from (
select Brand, 'AA' AA , NULL AAA, NULL C , NULL D
from my_table
where size ='AA'
union ALL
select Brand, null , 'AAA' , NULL , NULL
from my_table
where size ='AAA'
union ALL
select Brand, null , null , 'C' , NULL
from my_table
where size ='C'
union ALL
select Brand, null , null , null, 'D'
from my_table
where size ='D'
) T
group by brand