Thanks, Adam. Guess for now, I'll settle for the solution.

Will

On Wed, Mar 25, 2009 at 10:25 PM, Adam <[email protected]> wrote:

>
> I think that you should add an average_rating field to your  model,
> and whenever you update the total_rating and num_of_rating columns,
> recompute the average rating and write that to the record as well.
> Then, you can query quite simply on the average rating field.  You
> will, of course, need to do the retrieval and updating of the record
> in a transaction.
>
> On Mar 25, 9:52 am, Will <[email protected]> wrote:
> > Hi there,
> >
> > I have a model like this,
> >
> > class Rating(db.Model):
> >     ...
> >     total_rating = db.IntegerProperty(required=True, default=0)
> >     num_of_rating = db.IntegerProperty(required=True, default=0)
> >
> > I'd like to return the top 10 average rating entities, like in SQL:
> >     ORDER BY total_rating/num_of_rating DESC           -- suppose
> > num_of_rating > 0
> >
> > Any ideas on how to archive this on GAE/GQL?
> >
> > Thanks,
> >
> > Will
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to