Yes I have id_situation field but do not know the sub query. 

The idea is to catch the last id_sutation person in a subquery

In SQL I managed to make fast

SELECT DISTINCT ON (p.name) p.name, (SELECT s.id_status from situation 
where s.id_person = p.id order by id desc limit 1) as status from person p
left join situation s on p.id = s.id_person
order by p.name, status desc;

the question is, how to do this using the DAL?

-- 
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.

Reply via email to