Try SQL outer join:
http://www.web2py.com/books/default/chapter/29/06#Left-outer-join



On Tuesday, 2 July 2013 02:09:19 UTC+1, Francisco wrote:
>
> Hi everyone.
>
> I'm trying to show how many logins every user has done in the last 7 days 
> in a view. I have the following query:
>
> log_count=db.auth_event.id.count()
> usrs = db((db.auth_user.hidden==False)&(db.auth_event.user_id==
> db.auth_user.id
> )&(db.auth_event.time_stamp<datetime_start)&(db.auth_event.time_stamp>datetime_end)&(db.auth_event.description.contains('Logged-in'))).select(db.auth_user.ALL,log_count)
>
> And it works ok, but only show user that have logged in in the last 7 
> days. I need to make this query to show 0 for user that have not logged in. 
> I have tried coalesce and distinct with no luck. And I have search the 
> forum and the docs and have found nothing.
>
> Could you guys help me out a little.
>
> Thank you.
>

-- 

--- 
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/groups/opt_out.


Reply via email to