This is a section of my dataset (for example flavours of ice cream and their ratings):
flavor | rating |
---|---|
cherry, apple, flower | 4.0 |
apple, chocolate, banana | 3.0 |
banane, chocolate, strawberry | 4.0 |
cherry, banane, strawberry | 1.0 |
Now I want to calculate the average rating of the flavours. So that I get following output:
flavor | avg(rating) |
---|---|
cherry | 2.5 |
apple | 3.5 |
banane | 2.66 |
strawberry | 2.5 |
chocolate | 3.5 |
flower | 4.0 |
How can I approach this in mysql?