I have the following query:
SELECT Sub_Type, count(Sub_Type)
FROM SOME_TABLE
GROUP BY Sub_Type
Sub_Type field type is an embedded list of string
The result I'm getting is:
Blotter_Sub_Type | count
["A"] | 2
["B"] | 3
["C"] | 3
["A","B"] | 1
["B","C"] | 1
But when I'm really after is to get how many occurrences of each value, my expected result is:
Blotter_Sub_Type | count
"A" | 3
"B" | 5
"C" | 4
Meaning that it will count the occurrences of each value individually
You have to use UNWIND and a subquery:
SELECT Sub_Type, count(Sub_Type) FROM (
SELECT Sub_Type FROM SOME_TABLE UNWIND Sub_Type
) GROUP BY Sub_Type