nachtrag, habe zu schnell gelesen. die aggregatfunktion brauchen nicht in die group by klausel.
demnach:
SELECT id, tothread, byid, datum, count(DISTINCT(tothread)) as threads FROM foren_posts WHERE forumid = '$row2[id]' GROUP BY tothread, id, byid, datum
Group by tothread, weil ich ja die gruppen an tothread haben will
(egal, ob ich es jetzt auch im count benutze oder nicht...)