如何在 Cosmos DB 中使用 WHERE COUNT

How to use WHERE COUNT in Cosmos DB

是否可以进行如下查询...

SELECT COUNT(UniqueLastNames)
FROM (
SELECT COUNT(c)
FROM c
WHERE COUNT(c.lastName) > 2 AND COUNT(c.lastName) < 5 GROUP BY c.lastName
) AS UniqueLastNames

它应该做的是把所有姓氏出现次数超过2次但少于5次的人都给我。

问题是,cosmos 不会让你在它说的 WHERE 语句中执行函数,还有其他方法吗?

得到它与以下代码一起工作...

SELECT COUNT(UniqueLastNames)
FROM (SELECT COUNT(1) AS lastName FROM c GROUP BY c.lastName) AS 
UniqueLastNames WHERE UniqueEmails.lastName > 2 AND UniqueEmails.lastName < 
5

...尽管它在 RU 上非常昂贵,每个请求 137.86 RU。