其他分享
首页 > 其他分享> > 查询最近3天连续登录的用户总数

查询最近3天连续登录的用户总数

作者:互联网


select SUM(count) from (  select COUNT(登录时间) as countValue,if(COUNT(登录时间)>=3,1,0)  count from (
            SELECT curdate() as mycreatedate
            union all
            SELECT date_sub(curdate(), interval 1 day) as mycreatedate
            union all
            SELECT date_sub(curdate(), interval 2 day) as mycreatedate
            ) as total
            LEFT JOIN (select * from 表名    where user_id in(SELECT
DISTINCT(用户id)
FROM
表名
WHERE
datediff(NOW(), 登录时间) <= 3))  weweicr   on DATE_FORMAT(weweicr.登录时间,'%Y-%m-%d')=total.mycreatedate   GROUP BY weweicr.用户id

  )  a   
 

标签:总数,登录,查询,mycreatedate,curdate,id,SELECT,select
来源: https://blog.csdn.net/ChuandongTan/article/details/121165738