问题
How can I get sum and average of packSOC and totalKw?
I am using dynamoDB as database but in my understanding dynamoDB does not support aggregate. How can I get average and sum of packSOC and totalKw.[Not possible to use for loop on result because result has so many data in it].
回答1:
At this time DynamoDB doesn't support this aggregation features.
If you want to collect these values you either have to keep track of them elsewhere or do the very inefficient collection scan and calculate it. Even if you reduce the output using projections that's likely not feasible.
If you need such functionality DynamoDB might not be a good pick for you and you should look at similar databases like MongoDB which does have a powerful aggregation framework. They do offer a cloud hosted version as well called MongoDB Atlas
来源:https://stackoverflow.com/questions/46196282/find-average-and-total-sum-in-dynamodb