描述
题目:现在运营想要查看用户在某天刷题后第二天还会再来刷题的平均概率。请你取出相应数据。 示例:question_practice_detailid | device_id | quest_id | result | date |
1 | 2138 | 111 | wrong | 2021-05-03 |
2 | 3214 | 112 | wrong | 2021-05-09 |
3 | 3214 | 113 | wrong | 2021-06-15 |
4 | 6543 | 111 | right | 2021-08-13 |
5 | 2315 | 115 | right | 2021-08-13 |
6 | 2315 | 116 | right | 2021-08-14 |
7 | 2315 | 117 | wrong | 2021-08-15 |
…… |
avg_ret |
0.3000 |
select count(date2)/count(date1) as avg_ret from( select distinct q.device_id, q.date date1, u_d.date date2 from question_practice_detail as q left join( select distinct device_id,date from question_practice_detail )as u_d on q.device_id = u_d.device_id and date_add(q.date,interval 1 day) = u_d.date )lat
标签:--,08,留存,wrong,device,2021,sql,date,id From: https://www.cnblogs.com/xinger123/p/16721409.html