Finally, FINALLY, I found what's the problem....
As I described above, it's impossible to determine the real source of the aggregate if they refer to the group by which refers to a join (or worse, as in this case, to a where which deep down refers to a join)... which side of the join is used? I've puzzled about this a couple of times before and had implemented some workarounds which would produce the right side, but obviously this doesn't always work, like in this query.
To my surprise I suddenly understood that the aggregate source is the same as the groupby source (i.e.: the elements grouped are the same as the elements aggregated). Yeah, pretty 'Duh!', if you ask me, but through all the expression goo it sometimes is a bit hard to find the causes of problems.
So this went OK, unless you grouped on a field in a related entity. THAT caused me a couple of hours, but I suddenly saw I ignored a complete lambda in the groupby method call. (as it was always the same as the groupby list). It's not the same in cases where the grouping is on related fields! So I've to connect these dots and then it should work
stay tuned.