try this..
SUMIFS($D$2:$D$11,$A$2:$A$11,IF(G2="","<>?",G2),$B$2:$B$11,G3,$C$2:$C$11,IF(G4="","<>?",G4))
A bit modified Asheesh's formula
In G6, enter formula and copied to J6 and M6 :
=IF(COUNTA(G2:G4)>0,SUMIFS($D:$D,$A:$A,IF(G2="","<>",G2),$B:$B,IF(G3="","<>",G3),$C:$C,IF(G4="","<>?",G4)),"")
Regards
Bosco