cosmosdb-server icon indicating copy to clipboard operation
cosmosdb-server copied to clipboard

GROUP BY

Open stuatnimble opened this issue 2 years ago • 0 comments

Having trouble with GROUP BY in a query.

Query

const { resources } = await myContainer.items
    .query({
      query:
        'SELECT MAX(t.inc) AS inc FROM t WHERE t.userId=@userId GROUP BY t.orgId',
      parameters: [
        {
          name: '@userId',
          value: userId,
        },
      ],
    })
    .fetchAll();

Error

The above works just fine using a real Cosmos NoSQL server, but errors with this one with the following...

Error: Expected "!=", "%", "&", "*", "+", "-", "--", ".", "/", "<", "<<", "<=", "<>", "=", ">", ">=", ">>", ">>>", "?", "??", "AND", "BETWEEN", "IN", "OR", "ORDER", "[", "^", "|", "||", [ \t\n\r], or end of input but "G" found.

Versions

"@vercel/cosmosdb-server": "^0.14.0", "@azure/cosmos": "^3.17.3", Node: 18.12.1

Thanks

stuatnimble avatar May 15 '23 09:05 stuatnimble