The formula in A9
=LET(a,GROUPBY(A2:A6,HSTACK(B2:B6,C2:C6),SUM), b,CHOOSECOLS(a,2)/CHOOSECOLS(a,3), HSTACK(a,b))