Hi, and thanks for replying!
Well, I finally opted to get all the values without grouping them, and looping through them with php.
But there must be a way to do it entirely with SQL.
Someone in another forum pointed me in the right direction, but apparently his example only works when one and only one aggregated value is NULL:
case max( case when val is null then 1 end )
when 1 then null
else sum( val )
group by id;