Azure Cosmos Document DB throws an error on executing a query like this -
SELECT DISTINCT VALUE
{
DocumentName: c.Name,
Count: COUNT(c.id),
Target: c.Target
}
FROM c where c.Target != null
Error -
SC2102: Property reference 'c.Name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
SC2102: Property reference 'c.Target' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
In regular SQL I would solve this by adding
GROUP BY c.Name, c.Target
at the end of the query but Cosmos DB does not seem to support a group clause.
SC1001: Syntax error, incorrect syntax near 'GROUP'.
I'm wondering if a GROUP-like clause is supported. And if it is not supported, what is the meaning of this error?