SELECT user.user_id,user.username,COUNT(Post_id) as message_count
FROM xf_post post
INNER JOIN xf_user as user ON user.user_id = post.user_id
WHERE message_state = 'visible' AND post.post_date >= (UNIX_TIMESTAMP()-86400) AND NOT ISNULL(user.user_id) $excludedusergroup
GROUP BY user.user_id
ORDER BY message_count DESC