Question

Comment puis-je trouver la valeur maximale dans une colonne particulière d'une table dans le GAE datastore en utilisant GQL?

Était-ce utile?

La solution

Pour obtenir le maximum vous en utilisant GQL, vous pouvez faire ceci:

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

Vous pouvez utiliser cette approche syntaxiquement plus courte mais équivalente:

max_x = MyModel.all().order('-x').get().x
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top