SELECT 
Agencja, Tytul, 
Sum(Netto) AS FakturaNetto, 
Sum(Brutto) AS FakturaBrutto, 
Sum(suma_zaplat) AS WplataBrutto

FROM         WplywyByTytul
WHERE     (YEAR(dataWplaty) = @rok) AND (MONTH(dataWplaty) IN (@ms)) AND (Tytul IN (@tytul)) AND (SystemKsiegowyId IN (@systemKsiegowy))
GROUP BY Agencja, Tytul