select ref,count(ref) as refsayi from users where ref in (select user_id from ch) group by ref order by refsayi desc