题解 | #工作日各时段叫车量、等待接单时间和调度时间#
牛客每个人最近的登录日期(五)
http://www.nowcoder.com/practice/ea0c56cd700344b590182aad03cc61b8
select a3.date,round(if(count(a1.user_id)=0,0,count(a2.user_id)/count(a1.user_id)),3) p
from (select user_id,min(date) date from login group by user_id) a1
left join (select distinct user_id,date from login) a2
on a1.user_id = a2.user_id and a2.date = date_add(a1.date,interval 1 day)
right join (select distinct date from login) a3 on a1.date = a3.date
group by a3.date
暴力联结,缺啥联啥