Thanks Cliff. But i don´t think it is that simple, or perhaps it is, but i can't manage to build the right query. If i use group by, it groups by the id and the having=max is ignored. all ids appear. Probably it needs joins. Will try to do the raw query and see if anyone can translate it. Thanks
El lunes, 10 de marzo de 2014 18:21:51 UTC-3, Cliff Kachinske escribió: > > 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

