Re: [web2py] Help with query with count not showing values for zero

2013-07-02 Thread Vinicius Assef
Your problem is about SQL.

You need to use LEFT JOIN. This will help you:
http://web2py.com/books/default/chapter/29/06#Left-outer-join

On Mon, Jul 1, 2013 at 9:49 PM, Francisco Betancourt
 wrote:
> Hi everyone.
>
> I want to show the number of logins for every user in the last 7 days in a
> view. I'm using this query:
>
> log_count=db.auth_event.id.count()
> usrs =
> db((db.auth_event.user_id==db.auth_user.id)&(db.auth_event.time_stampdatetime_end)&(db.auth_event.description.contains('Logged-in'))).select(db.auth_user.ALL,log_count)
>
> This is working, except that user that have not logged in in the last 7 days
> won't show up as a result in my query.
>
> Could some one help correct my query? I have search through out the forum
> and docs but couldn't find and answer. And when googling for an answer in
> SQL it talks about COALESCE and also DISTINCT and tried both but had no
> luck.
>
> Thanks.
>
> --
>
> ---
> 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/groups/opt_out.
>
>

-- 

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




[web2py] Help with query with count not showing values for zero

2013-07-02 Thread Francisco Betancourt
Hi everyone.

I want to show the number of logins for every user in the last 7 days in a 
view. I'm using this query:

log_count=db.auth_event.id.count()
usrs = 
db((db.auth_event.user_id==db.auth_user.id)&(db.auth_event.time_stampdatetime_end)&(db.auth_event.description.contains('Logged-in'))).select(db.auth_user.ALL,log_count)

This is working, except that user that have not logged in in the last 7 
days won't show up as a result in my query.

Could some one help correct my query? I have search through out the forum 
and docs but couldn't find and answer. And when googling for an answer in 
SQL it talks about COALESCE and also DISTINCT and tried both but had no 
luck.

Thanks.

-- 

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