Vous pouvez simplifier votre requête et utiliser LEAST fonction
SELECT USERid, LEAST(7, COUNT(*))
FROM table
GROUP BY USERid
de la question dans votre commentaire
SELECT SUM(countByUser)
FROM
(SELECT LEAST(7, COUNT(*)) as countByUser
FROM table
GROUP BY USERid) c