SELECT ROUND(
    (SELECT COUNT(DISTINCT user_id) 
     FROM login a
     WHERE EXISTS (
         SELECT 1 
         FROM login AS b 
         WHERE a.user_id = b.user_id 
         AND DATE_ADD(a.date, INTERVAL 1 DAY) = b.date)
    ) * 1.0 / 
    (SELECT COUNT(DISTINCT user_id) 
     FROM login), 
3) AS p;


#连续两天 且是 第一天和第二天 且 同一天同一user_id只能统计一次 然后 连登两天/初次登陆

/*select round(count(distinct user_id)*1.0/(select count(distinct user_id) from login),3)
from login
where (user_id,date) in 
(select user_id,date_add(min(date),interval 1 day) 
from login 
group by user_id)*/