select
round((count(distinct d.user_id))/count(distinct c.user_id) ,3) as p
from
login c
left join (
select
a.user_id, client_id, date, first_day, second_day
from
login a,
(
select
user_id,
min(date) as first_day,
date_add(min(date), interval 1 day) as second_day
from
login
group by
user_id
) b
where
a.user_id = b.user_id
and a.date = b.second_day
) d on c.user_id = d.user_id

京公网安备 11010502036488号