开发者

Finding the maximum value in a column using GQL

开发者 https://www.devze.com 2023-01-19 06:43 出处:网络
How do I find the maximum value in a particular column of a table 开发者_如何学Goin the GAE datastore using GQL?To get the max you using GQL, you could do this:

How do I find the maximum value in a particular column of a table 开发者_如何学Goin the GAE datastore using GQL?


To get the max you using GQL, you could do this:

max_x = db.GqlQuery("SELECT * FROM MyModel ORDER BY x DESC").get().x

You could use this syntactically shorter but equivalent approach:

max_x = MyModel.all().order('-x').get().x
0

精彩评论

暂无评论...
验证码 换一张
取 消