sollte ziemlich genau das machen was ich denke was du willstCode:SELECT b2.*, COUNT(data.uid) as anzahl FROM vms_bonus as b2 LEFT JOIN ( SELECT u.uid, MAX(b.id) as bonusrang FROM vms_kontodaten u RIGHT JOIN vms_bonus AS b ON u.ap>=b.benoetigte_ap GROUP BY u.uid) as data ON b2.id=data.bonusrang GROUP BY b2.id ORDER BY b2.benoetigte_ap ASC;