SQL每日一题(20230802)

2024-04-24 17:52:53 浏览数 (2)

题目

表G0802中的字段时user_id,time(用户访问时间)

求每个用户相邻两次浏览时间之差小于三分钟的次数预计结果如下:

测试数据

代码语言:javascript复制
CREATE TABLE G0802 (
user_id INT,
times DATETIME
)

INSERT INTO G0802 VALUES (1,'2020-12-7 21:13:07');
INSERT INTO G0802 VALUES (1,'2020-12-7 21:15:26');
INSERT INTO G0802 VALUES (1,'2020-12-7 21:17:44');
INSERT INTO G0802 VALUES (2,'2020-12-13 21:14:06');
INSERT INTO G0802 VALUES (2,'2020-12-13 21:18:19');
INSERT INTO G0802 VALUES (2,'2020-12-13 21:20:36');
INSERT INTO G0802 VALUES (3,'2020-12-21 21:16:51');
INSERT INTO G0802 VALUES (4,'2020-12-16 22:22:08');
INSERT INTO G0802 VALUES (4,'2020-12-2 21:17:22');
INSERT INTO G0802 VALUES (4,'2020-12-30 15:15:44');
INSERT INTO G0802 VALUES (4,'2020-12-30 15:17:57');

参考答案

0 人点赞