简体   繁体   English

OrientDB在EmbeddedList列上执行分组

[英]OrientDB perform a group by on embeddedlist column

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 Sub_Type字段类型是字符串的嵌入式列表

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: 您必须使用UNWIND和一个子查询:

SELECT Sub_Type, count(Sub_Type) FROM (
   SELECT Sub_Type FROM SOME_TABLE UNWIND Sub_Type
) GROUP BY Sub_Type

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM