问题描述:
一张表:student_schedule(学生课程表)
字段comment:学生ID,课程ID,完成时间
问题:学生在一天内完成一节课,当前天记录为完成学习,现计算连续学习天数
————————————————————————————————————————————————————————————————————————
思路:
连续学习,使用排序和完成时间做对比
————————————————————————————————————————————————————————————————————————
数据准备:
1、
create table if not exists student_schedule(
student_id bigint
,lesson_id bigint
,finish_date STRING
);
2、
insert OVERWRITE table student_schedule
select 1,100,'2019-08-01 00:00:00'
union all
select 1,200,'2019-08-01 00:00:00'
union all
select 1,100,'2019-08-02 00:00:00'
union all
select 1,200,'2019-08-02 00:00:00'
union all
select 1,100,'2019-08-03 00:00:00'
union all
select 1,200,'2019-08-03 00