I have label
- its array of strings value (mysql json
type) like: ["foo", "bar"]
and I would like to get avarage for those values like:
Example 1
ID | LABEL
1 | ["foo"]
2 | ["foo"]
3 | ["foo"]
4 | ["foo"]
Output: foo
: 100%
Example 2
ID | LABEL
1 | ["foo"]
2 | ["foo"]
3 | ["bar"]
4 | ["bar"]
Output: foo
: 50%
Output: bar
: 50%
Example 3
ID | LABEL
1 | ["foo", "bar"]
2 | ["foo", "bar"]
Output: foo
: 50%
Output: bar
: 50%
How can I do it with single sql?
its possible?
I don't know which code should I use.