Complex & Multiple self::STAT

I’m trying to figure out a way to pull a bunch of stats in one query, like: COUNT(id), SUM(comment_rating) without using 2 self::STAT methods which involves two separate queries.

I want to do this all in the relation() model function.

I’ve gotten to where I do self::HAS_ONE and do a group by on that statement, but it doesn’t write it as it’s own separate query, it does the JOIN first on the entire query and then the group by on the whole thing.

In a way I want to run the relation as a temp table object that holds valuable SQL calculations.

Anyone know of a way around this? It’s sort of two separate problems…but would love to know the answer to both if there is one!