Also, rather than doing a separate query for each item in the view, you might do a join and get the max value directly in the controller. This might not be quite right, but something like:
max = db.price.weekly.max() items = db(db.listing_item.id == db.price.listing).select(db.listing_item.id, db.listing_item.title, max, groupby=db.listing_item.id) Anthony On Saturday, October 8, 2011 10:44:33 PM UTC-4, Anthony wrote: > > On Saturday, October 8, 2011 10:31:18 PM UTC-4, IK wrote: >> >> >> {{for item in item:}} >> <div> Listing {{item.title}} and max price: >> >> {{prices=db((db.price.id>0) & >> (db.price.listing==item)).select(db.price.weekly,distinct=True)}} >> > > 'item' is an entire row -- instead, you want item.id: > > (db.price.listing==item.id) > > Also, you shouldn't need the (db.price.id>0). > > You might also want to name the result of the select in the controller > 'items' instead of 'item' to avoid confusion. > > >> {{priceMax= prices.last()}} >> > > Are the prices inserted in order, so the last is always the max? > > >> {{=priceMax}} >> > > If you don't need to re-use priceMax elsewhere, you can just do: > > {{=prices.last().weekly}} > > Anthony >