SELECT u.*,count(u.id) AS sum FROM user AS u LEFT JOIN post AS p ON p.user_id = u.id RIGHT JOIN user_has_group as up ON up.user_id = u.id RIGHT JOIN user_has_email as ue ON ue.user_id = u.id WHERE u.username != '' AND up.group_id = {$args['groupid']} AND ue.email = '{$args['useremail']}' GROUP BY u.id ORDER BY u.id desc