How do I write the corresponding web2py statement for the following query:
select auth_user.id, min(auth_group.ranks) as highest_gr
from auth_user
left join auth_membership on auth_user.id = auth_membership.user_id,
left join auth_group on auth_membership.group_id = auth_group.id
I haven't written pure SQL in a while, there must be a group by somewhere but the idea is there.
Edit: I'm trying to retrieve all records from auth_user with their corresponding highest group ranks.
I used the following code:
queryis defined somewhere asquery = (db.auth_user.id >0)