1

I have the following query:

SELECT DISTINCT c.deviceId, c._ts FROM c

ORDER BY c._ts DESC

I would like to receive only one pair (c.deviceId, c._ts) per deviceId, but because the c._ts value is distinct for all entries, I am getting all the value-pairs for all deviceIds, with other words my whole DB.

I have tried to use Question: Distinct for only one value as a guide, but I see that CosmosDB does not support GROUP BY.

Is there a way to do this in cosmosDB?

Haukland
  • 677
  • 8
  • 25

1 Answers1

0

Though it's a common requirement i think,i can't implement it on my side as same as you. The distinct keyword can't work on one single column cross whole query result.

Group by feature is currently in active development for a long period,based on the latest comment in this voice,it is coming soon.

If your need is urgent ,as workaround, you could follow this case to use documentdb-lumenize package which supports Aggregate Functions.

Jay Gong
  • 23,163
  • 2
  • 27
  • 32