当前位置: 首页 > article >正文

hive-sql 连续登录五天的用户

with tmp as (
          select '梁牧泽' as uid, '2023-03-03' as `dt` union all
          select '梁牧泽' as uid, '2023-03-04' as `dt` union all
          select '梁牧泽' as uid, '2023-03-05' as `dt` union all
          select '梁牧泽' as uid, '2023-03-07' as `dt` union all
          select '梁牧泽' as uid, '2023-03-08' as `dt` union all
          select '梁牧泽' as uid, '2023-03-09' as `dt` union all
          select '梁牧泽' as uid, '2023-03-10' as `dt` union all
          select '梁牧泽' as uid, '2023-03-11' as `dt` union all
          select '梁牧泽' as uid, '2023-03-12' as `dt` union all
          select '夏初' as uid, '2023-03-10' as `dt` union all
          select '夏初' as uid, '2023-03-10' as `dt` union all
          select '夏初' as uid, '2023-03-11' as `dt` union all
          select '夏初' as uid, '2023-03-12' as `dt` union all
          select '夏初' as uid, '2023-03-13' as `dt` union all
          select '夏初' as uid, '2023-03-14' as `dt` union all
          select '夏初' as uid, '2023-03-15' as `dt`
) 
select 
uid,
dt,
follow_5_dt
from 
(select uid,dt
,last_value(dt) over(partition by uid order by dt asc rows between current row and 4 following) as follow_5_dt
,datediff(last_value(dt) over(partition by uid order by dt asc rows between current row and 4 following),dt) as diff_day
from tmp ) t where diff_day=4

结果:

 


http://www.kler.cn/a/458815.html

相关文章:

  • 《Vue进阶教程》第三十一课:ref的初步实现
  • MySQL数据库笔记——多版本并发控制MVCC
  • idea 开发Gradle 项目
  • 后端技术面试38讲之程序为什么会崩溃?
  • HarmonyOS开发:关于帧动画使用分享
  • MAC系统QT图标踩坑记录
  • 【GeekBand】C++设计模式笔记18_State_状态模式
  • 【2024年-6月-21日-开源社区openEuler实践记录】探索 intel-kernel:英特尔架构内核优化之路
  • [TOTP]android kotlin实现 totp身份验证器 类似Google身份验证器
  • 环,域,体,整区,理想,极大理想,
  • 配置hive支持中文注释
  • Lombok是银弹?还是陷阱?
  • golang标准库archive/tar实现打包压缩及解压
  • 《Java核心技术 卷II》流的创建
  • Vue el-data-picker选中开始时间,结束时间自动加半小时
  • 滑动窗口、流量控制和拥塞控制
  • C++笔记-对windows平台上lib和dll的进一步理解(2024-10-21
  • YOLOv8实战车辆目标检测
  • js混淆中 p[‘name‘] 来访问属性的好处
  • 若依前后端分离项目部署(使用docker)
  • C++ 设计模式:职责链模式(Chain of Responsibility)
  • MySQL:一文弄懂时区time_zone
  • 远程调用服务器jupter调试程序
  • word运行时错误‘-2147221164(80040154)’ 没有注册类的解决办法
  • C++ 设计模式:备忘录模式(Memento Pattern)
  • omi friend实战记录