Hello,
I have the entities Contribution (ie a forum thread), Category and User. Now, I'd like to fetch the category in which a user has written most contributions. I've tried this:
Code:
SELECT cat, count(cat.id) AS am
FROM
Category cat, IN (cat.contributions) c
WHERE
c.user=:user
GROUP BY
cat.id
ORDER BY am DESC
but it will fail on ORDER BY am, telling me it's not a column.
I've also tried something like this
Code:
SELECT cat
FROM
Category cat, IN (cat.contributions) c
WHERE
c.user=:user
GROUP BY
cat.id
HAVING count(cat.id) = max(count(cat.id))
but this wont work either (illegal use of group function).
Can anyone help me out or give me a clue?
- Frode