Doesn't work ... correct me if I'm wrong, but the distinct() will return distinct knowledge ids ... and if I add it after the where_related then it will return distinct group ids.
So I have a users table, a knowledge table and a groups table.
a user creates many knowledge items and each knowledge item gets published to multiple groups. If a knowledge item isn't published its a draft. This query returns the number of groups knowledge items have been published to. So even if a single item has been published to three knowledge items, it will return three, as compared to one.
I've tried a group by as well .. no dice :[
This isn't all that vital .. I am going to have a process running that will update these values in the user table rather than running complex queries over and over again