Question, why are you using a join with a subquery that does use the same table with the same conditions?
If the Member asociation is a OneToOne it should work the same as without subquery.
As for how to build the sum and case expr with query builder, you can see a post i did some time ago using count distinct with case