用户两天留存率 数据列:
id device_id quest_id result date
select count(date2) / count(date1) as avg_ret
from
(select distinct d1.device_id, d1.date as date1, d2.date as date2
from question_practice_detail d1
left join(
select distinct device_id, date
from question_practice_detail) d2
on d1.device_id = d2.device_id
and date_add(d1.date, interval 1 days) = d2.date
)a
【mysql|每日sql -用户两天留存率】select avg(if(datediff(date2,date1)= 1,1,0)) as avg_ret
from(
select distinct device_id,date as date1,lead(date) over(partition by device_id order by date) as date2
from (select distinct device_id,date from question_practice_detail) b
)a
推荐阅读
- PDManer [元数建模]-v4.0 (一款简单好用的数据库建模平台)
- 渗透测试领域.|Python 开发 利用SQLmap API接口进行批量的SQL注入检测.(SRC挖掘)
- 腾讯云数据库TDSQL两大引擎全新升级,分析能力和Oracle兼容能力大幅提升
- 大数据|Flink CDC + Hudi + Hive + Presto 构建实时数据湖最佳实践
- 大数据|「Hudi系列」Apache Hudi入门指南 | SparkSQL+Hive+Presto集成
- 更改Apollo数据库为oracle
- MySQL 字段约束
- mysql|MySQL经典50题
- 脚本部署mysql