nova
nova

Reputation: 313

How to query the greates value (sortkey/range) dynamodb?

Maybe this is a very simple question but I didn't find a suitable solution for this. I have a secondary key /range key /sort key, what ever and its value is a number. So in the Table a several items with this key and I want to get the Item with the greatest number/value. I found this at stack overflow but this does not look like something from the aws documentation. In this documentation you can find gt or ge but I don't want to compare the value with a number, I want the greatest ... Maybe you can help

Upvotes: 1

Views: 527

Answers (1)

birnbaum
birnbaum

Reputation: 4966

If the property you want to query is your sort/range key, you only need to set ScanIndexForward=false (order descending) and set the Limit to 1

Upvotes: 2

Related Questions