select favorite_count_per_member.members, (favorite_count / (select count(*) from content_favorites where members = )) as ratio, members.*
from members left join ( select members, count(*) as favorite_count
from content_favorites
where content_id in (
select content_id from content_favorites
where members =
)
group by members) as favorite_count_per_member on (favorite_count_per_member.members = members.members_id)
order by ratio desc
|