select daybook.userid, count(*) as count
from daybook, rating
where daybook.userid = rating.userid
group by daybook.userid
order by count desc
しかし、実際には日記の表は必要ありません:
select userid, count(*) as count
from rating
group by userid
order by count desc