当前位置:网站首页>用户连续登陆(允许中断)查询sql
用户连续登陆(允许中断)查询sql
2022-07-23 05:41:00 【AA赵师傅】
select
user_id,
max(days)
from (
select user_id,
f,
count(1) days
from (
select user_id,
login_time,
sum(if(flag > 2 , 1, 0)) over (partition by user_id order by login_time) f
from (
select user_id,
login_time,
lag(login_time, 1, '1970-01-01') over (partition by user_id order by login_time) last_login_time,
datediff(login_time,lag(login_time, 1, '1970-01-01') over (partition by user_id order by login_time)) flag
from login
) t1
group by user_id, login_time
) t2
group by user_id, f
) res
group by user_id边栏推荐
猜你喜欢
随机推荐
Project process summary
NFT数字藏品系统开发,数字藏品的发展趋势
自定义MVC(上)
MySQL索引&&执行计划
CTF-web 常用软件安装及环境搭建
自定义MVC的使用&增删改查
[untitled]
js的防抖和节流
JS event loop
Application of higher-order functions: handwritten promise source code (III)
The 6th "Blue Hat Cup" National College Students' Cyber Security Skills Competition - preliminary writeup
some、every、find、findIndex的用法
Custom MVC (Part 1)
C语言之二分查找法或折半查找法剖析(经典例题,经典解析)
NFT数字藏品开发:京东“奇达熊带你游京城”旅游套装
How pycharm packages OCR correctly and makes the packaged exe as small as possible
数字藏品系统开发:企业布局元宇宙数字藏品
Vite x sigma creates designer specific I18N plug-ins
Setting optimization and use of MySQL and SQL Server
基于el-table的树形表格及js-xlsx实现下载excel功能(二)









