OrientDB 在 embeddedlist 列上执行分组
OrientDB perform a group by on embeddedlist column
我有以下查询:
SELECT Sub_Type, count(Sub_Type)
FROM SOME_TABLE
GROUP BY Sub_Type
Sub_Type 字段类型是字符串的嵌入列表
我得到的结果是:
Blotter_Sub_Type | count
["A"] | 2
["B"] | 3
["C"] | 3
["A","B"] | 1
["B","C"] | 1
但是当我真正想要得到每个值出现的次数时,我的预期结果是:
Blotter_Sub_Type | count
"A" | 3
"B" | 5
"C" | 4
意味着它将单独计算每个值的出现次数
您必须使用 UNWIND 和子查询:
SELECT Sub_Type, count(Sub_Type) FROM (
SELECT Sub_Type FROM SOME_TABLE UNWIND Sub_Type
) GROUP BY Sub_Type
我有以下查询:
SELECT Sub_Type, count(Sub_Type)
FROM SOME_TABLE
GROUP BY Sub_Type
Sub_Type 字段类型是字符串的嵌入列表
我得到的结果是:
Blotter_Sub_Type | count
["A"] | 2
["B"] | 3
["C"] | 3
["A","B"] | 1
["B","C"] | 1
但是当我真正想要得到每个值出现的次数时,我的预期结果是:
Blotter_Sub_Type | count
"A" | 3
"B" | 5
"C" | 4
意味着它将单独计算每个值的出现次数
您必须使用 UNWIND 和子查询:
SELECT Sub_Type, count(Sub_Type) FROM (
SELECT Sub_Type FROM SOME_TABLE UNWIND Sub_Type
) GROUP BY Sub_Type