Hi villas, thanks for your example but that delivers the wrong result. With your query we get
name date amount aaa 2016-01-15 15 bbb 2016-01-20 10 ccc 2016-01-25 29 The result with your data should be (perhaps with additional price column) name date amount (price) aaa 2016-01-15 15 10 bbb 2016-01-20 6 15 ccc 2016-01-25 25 20 I want the last/max val_date for each prop_id and the amount of this last val_date; in your query you just select the max val_date and the max amount. With maxdate = db.prop_val.val_date.max() rows1 = db().select(db.prop_val.prop_id, maxdate, groupby=db.prop_val.prop_id) I get the last date for each prop_id; but after that how do I get the amount for that prop_id/date and combine this result with the name and price for each prop (in the most simple way)? stex -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.