Moin Moin !
id | thema | rating
1 | 1 | 10
2 | 1 | 8
3 | 2 | 9
4 | 1 | 7
5 | 2 | 8
6 | 2 | 10normalerweise mache ich eine Abfrage mit avg(rating)
um Beispielsweise als Ergebnis dies zu bekommen:thema2 : 9
thema1 : 8.333
Mal ins Blaue geraten:
SELECT thema,AVG(rating.rating) as av_rating FROM rating GROUP BY thema WHERE av_rating >= 9
oder, etwas weniger effizient:
SELECT thema,AVG(rating.rating) as av_rating FROM rating GROUP BY thema HAVING av_rating >= 9
Ich finde es übrigens etwas ungeschickt, eine Tabellenspalte genauso zu nennen wie die Tabelle selbst.
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so!"
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so!"