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