How do I get the latest record for each item in CosmosDB using SQL
问题 I have a schema which is similar to "id": "uuid", "deviceId": "uuid", "message": { "content": "string", "ts": 1 }, "data": { "temperature": 21 } I'd like to get the latest "data" (using message.ts as the timestamp) for each "deviceId". So far, I've managed to get the data back, in order of timestamp using the query SELECT c.deviceId, c.message.ts, c.data FROM c ORDER BY c.message.ts DESC but I can't figure out how to remove the duplicate device records. Is this possible to do within the