我有 3 个文档,我想获取数组中存在的键的计数。 以下是文件:-
[
{
appId: "f1606a90-c96f-4db9-8e5f-9f0b6d2d2116",
attributes: [
{
"activity": "Brand Management",
},
{
"priority": "No"
},
{
"numberOfLine": 6
}
]
},
{
appId: "f1606a90-c96f-4db9-8e5f-9f0b6d2d2116",
attributes: [
{
"activity": "Brand Management",
}
]
},
{
appId: "f1606a90-c96f-4db9-8e5f-9f0b6d2d2116",
attributes: [
{
"activity": "Upsert",
},
{
"mailStatus": "Assigned"
}
]
}
查询:-
SELECT RAW
count(1)
FROM
workflow wf
UNNEST wf.attributes attr
WHERE
wf.appId = "f1606a90-c96f-4db9-8e5f-9f0b6d2d2116"
AND
attr.activity == 'Brand Management';
结果:-
[
2
]
预期结果:-
[
{
"Brand Management" : 2
}
]
我正在寻找结果,它将给我输出作为活动名称和该活动的计数。任何线索都会非常有帮助。