我也写一个,其实主要解决思路就是要让连续的两条记录之间产生联系。
CREATE TABLE login_log
(
user_id integer,
login_date date
);
insert into login_log values(1,'2020-01-01');
insert into login_log values(1,'2020-01-02');
insert into login_log values(1,'2020-01-04');
insert into login_log values(1,'2020-01-05');
insert into login_log values(1,'2020-01-06');
insert into login_log values(1,'2020-01-07');
insert into login_log values(1,'2020-01-08');
insert into login_log values(1,'2020-01-09');
insert into login_log values(1,'2020-01-10');
insert into login_log values(1,'2020-01-12');
insert into login_log values(1,'2020-01-13');
insert into login_log values(1,'2020-01-15');
insert into login_log values(1,'2020-01-16');
insert into login_log values(2,'2020-01-01');