问题描述
在CosmosDb查询中是否有直接函数来计算不同元素?
Is there a direct function to count distinct elements in a CosmosDb query?
这是默认计数:
SELECT value count(c.id) FROM c
还有无数的独特作品:
SELECT distinct c.id FROM c
但这将返回错误的请求-语法错误:
But this returns a Bad Request - Syntax Error:
count
和distinct
如何一起工作?
推荐答案
2019年5月15日,上面的注释适用于Where
条件,我没有尝试使用Join
,但请求确实返回了我要寻找的答案.
On 15 May 2019, The comment above is working with Where
condition, I didn't try with a Join
but the request does return the answer I'm looking for.
它正在处理CosmosDB中100个元素的限制.
And it is working with the 100 elements limitation in CosmosDB.
如果我用Product做一个例子,应该是:SELECT COUNT(1) FROM (SELECT DISTINCT c.Id FROM c WHERE c.Brand = 'Coca')
If I make an example with Product it should be :SELECT COUNT(1) FROM (SELECT DISTINCT c.Id FROM c WHERE c.Brand = 'Coca')
这篇关于CosmosDb计算不同元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!