当前位置:网站首页>MySQL面试真题(十九)——抖音-选出每个月有连续登录2天的用户名单
MySQL面试真题(十九)——抖音-选出每个月有连续登录2天的用户名单
2022-06-22 07:04:00 【Socialphobia_FOGO】
选出每个月有连续登录2天的用户名单
有一张“用户登陆记录表”,包含两个字段:用户id、日期。
结果如下:
#查询2021年每个月,连续2天都有登陆的用户名单。
SELECT DISTINCT
MONTH(日期) AS 月,
用户id
FROM
(SELECT
*,
lead (日期) over (
PARTITION BY 用户id,
MONTH(日期)
ORDER BY 日期
) AS 本月下次登录日期
FROM
用户登陆记录表
WHERE YEAR(日期) = 2021) a
WHERE DATEDIFF(
本月下次登录日期,
日期
) = 1
ORDER BY 月
边栏推荐
- OpenGL - Textures
- Qt development simple Bluetooth debugging assistant (low power Bluetooth)
- How can we effectively alleviate anxiety? See what ape tutor says
- sessionStorage 和 localStorage 的使用
- QT connect to Alibaba cloud using mqtt protocol
- [fundamentals of machine learning 03] gbdt (gradient boost decision tree)
- Xh_CMS渗透测试文档
- 【GAN】《ENERGY-BASED GENERATIVE ADVERSARIAL NETWORKS》 ICLR‘17
- How to prevent event propagation in JS
- Correspondence between pytorch and torchvision
猜你喜欢

CNN模型合集 | Resnet变种-WideResnet解读

cookie的介绍和使用

Tpflow v6.0.6 official release

5G NR PWS系统

【GCN-RS】UltraGCN: Ultra Simplification of Graph Convolutional Networks for Recommendation (CIKM‘21)

The journey of an operator in the framework of deep learning

Multi camera data collection based on Kinect azure (II)

Introduction to 51 single chip microcomputer - matrix key

2022-06-21:golang选择题,以下golang代码输出什么?A:3;B:4;C:100;D:编译失败。 package main import ( “fmt“ ) func

vue连接mysql数据库失败
随机推荐
OpenGL - Textures
Buuctf part Title WP
vue连接mysql数据库失败
Several methods of array de duplication in JS
Introduction to 51 Single Chip Microcomputer -- the use of Keil uvision4
June training (day 22) - orderly gathering
Quelles industries les diplômés recherchent - ils en 2022?
【GAN】W-GAN ICLR‘17, ICML‘17
【GCN-RS】UltraGCN: Ultra Simplification of Graph Convolutional Networks for Recommendation (CIKM‘21)
首次用DBeaver连接mysql报错
流程引擎解决复杂的业务问题
Error when connecting MySQL with dbeaver for the first time
Yolov1 (prediction process)
The tidb community offline exchange meeting was seen by the partners from Tianjin and Shijiazhuang~
Reprint the Alibaba open source project egg JS technical documents cause "copyright disputes". How to use the loose MIT license?
Introduction to 51 single chip microcomputer - 8x8 dot matrix LED
golang調用sdl2,播放pcm音頻,報錯signal arrived during external code execution。
Leetcode: interview question 08.12 Eight queens [DFS + backtrack]
六月集训(第22天) —— 有序集合
June 21, 2022: golang multiple choice question, what does the following golang code output? A:3; B:4; C:100; D: Compilation failed. package main import ( “fmt“ ) func