Considere the table:
+--------+-------+
| id | value |
+--------+-------+
| 1 | A |
| 1 | B |
| 2 | A |
| 2 | B |
| 3 | A |
| 3 | B |
| 3 | C |
| 4 | A |
+--------+-------+
and I want to count the group of values
based on the id
column. The result will be like:
+--------+---------+
| count | value |
+--------+---------+
| 2 | A B |
| 1 | A B C |
| 1 | A |
+--------+---------+
Note that the cardinality of column value
is dynamic.
I've tried pivoting with some subqueries but I'm not sure if I'm going in the correct way.
I appreciate any help given.