首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >检查用户在执行某些操作后是否未登录

检查用户在执行某些操作后是否未登录
EN

Stack Overflow用户
提问于 2021-05-28 13:24:15
回答 1查看 43关注 0票数 0

我的任务是:

导出了创建>=1费用但在创建后7天没有登录应用程序的客户列表(5月3日至9日)

我需要以某种方式创建一个逻辑,以检查用户在创建自己的开销之后是否没有登录,但我在SQL方面几乎是绿色的,所以我不知道这一切是如何工作的。目前,我只创建了一个逻辑,它获取所有用户并检查在时间线(即5月3日至9日)中创建的发票。

如何检查用户是否在7天内没有登录。

代码语言:javascript
复制
select u.*
from users_user u
where u.completed_registration 
and exists (
   select id
   from operation_operation op
   where op.company_id = u.active_company_id
)
and exists (
   select id
   from invoice_invoice inv
   right join operation_operation op
   on inv.operation_ptr_id = op.id
   and op.created_at between '2021-05-03 00:00:00' and '2021-05-09 00:00:00' /*specify the date of the creation (3-9 May) */
   group by id having count(*) >= 1
)
/* 
How can we check if the user wasn't logged in after the creation for 7days 
we use "u.last_login" for our user last online date 
*/
EN

回答 1

Stack Overflow用户

发布于 2021-05-28 15:02:12

您的查询中有一个错误,让我试着解释一下:

这将使用u.completed_registration选择您的用户。

代码语言:javascript
复制
select u.*
from users_user u
where u.completed_registration

一定有一个operation_operationu.active_company_id注释中:这个operation_operation可能与那个用户无关,它也可能涉及到该公司的另一个用户!

代码语言:javascript
复制
and exists (
   select id
   from operation_operation op
   where op.company_id = u.active_company_id
)

而且必须有一个以上的发票,(但这张发票似乎没有对用户的参考?)

代码语言:javascript
复制
and exists (
   select id
   from invoice_invoice inv
   right join operation_operation op
   on inv.operation_ptr_id = op.id
   and op.created_at between '2021-05-03 00:00:00' and '2021-05-09 00:00:00' /*specify the date of the creation (3-9 May) */
   group by id having count(*) >= 1
)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67739716

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档