The DAL chapter of the online Web2py manual explains how to fetch the max value, same as a SQL GROUP BY.
On Monday, March 10, 2014 3:54:59 PM UTC-4, brahama von wrote: > > This is the result i get from a simple select like this: > > legacy_db(legacy_db.cursodado.gp_pro_id==course).select() > > cursodado.gp_id cursodado.gp_pro_id cursodado.gp_historicdate > cursodado.gp_curso_id > > 10003600042014-01-27 16:02:10None > > > 10003600042014-01-27 17:18:31None > > > 10003600042014-01-27 17:21:02None > > > 10005250042014-01-27 16:02:10None > > > 10005250042014-01-27 17:18:31None > > > 10005250042014-01-27 17:21:02None > > > > > > > > > > Here i get the id of the person and the id of the course but I want only > to show the first I once, that correspond to the > max(cursodado.gp_historicdate) > To see it like this: > > cursodado.gp_id cursodado.gp_pro_id cursodado.gp_historicdate > cursodado.gp_curso_id > > > > > > > > > 10003600042014-01-27 17:21:02None > > > > > > > > > 10005250042014-01-27 17:21:02None > > tried this in the select but it gives a timeout: > > select(groupby=gp_id,having=max(historicdate field)) > > Thanks! > -- 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.