要统计的一天=第一天=atc_task_logs_20211117
第二天=atc_task_logs_20211118


一 第一天每个小类型创建数

1
select task_name,count(*) from atc_task_logs_20211117 where event=1 group by task_name

二 第一天创建的所有任务的独一标志hashKey

return${第一天创建的hashKey集合}

1
select hash_key from atc_task_logs_20211117   where event=1 and hash_key is not null

三 统计当天成功和第二天成功

1
2
3
4
5
6
7
8
9
10
11
12

当天成功
select task_name,count(*) from atc_task_logs_20211117
where event=4
and hash_key in ${第一天创建的hashKey集合}
group by task_name

第二天成功
select task_name,count(*) from atc_task_logs_20211118
where event=4
and hash_key in ${第一天创建的hashKey集合}
group by task_name

四 类似第三步 统计当天强制失败和第二天强制失败

1
2
3
4
5
6
7
8
9
10
11
12

当天失败
select task_name,count(*) from atc_task_logs_20211117
where event=7
and hash_key in ${第一天创建的hashKey集合}
group by task_name

第二天强制失败
select task_name,count(*) from atc_task_logs_20211118
where event=7
and hash_key in ${第一天创建的hashKey集合}
group by task_name

五 第一天创建的hashKey第二天也出现了 说明最后一次event出现在第二天

return ${结束在第二天的event的id的集合}

1
2
3
4
select max(id) from atc_task_logs_20211118
where
hash_key in ${第一天创建的hashKey集合}
group by hash_key

五点五 第一天创建的hashKey第二天也出现了 说明最后一次event出现在第二天

return ${结束在第二天的hashKey集合}

1
2
3
4
select hash_key from atc_task_logs_20211118
where
hash_key in ${第一天创建的hashKey集合}
group by hash_key

六 统计第一天的(event=5)失败

${第一天创建的hashKey集合} - ${结束在第二天的hashKey集合} = ${结束在第一天的hashKey集合}

1
2
3
4
5
6
7
8
9
10
11
12
13

select max(id) from atc_task_logs_20211117
where
hash_key in ${结束在第一天的hashKey集合}
group by hash_key



select task_name,count(*) from atc_task_logs_20211117
where
event=5
and id in ${结束在第一天的eventid的集合}
group by task_name

七 类似地 统计下第二天的(event=5)失败

1
2
3
4
5
select task_name,count(*) from atc_task_logs_20211118
where
event=5
and id in ${结束在第二天的eventid的集合}
group by task_name