1、背景
有一张单据审批日志表,表中数据样例如下:
ID | INCIDENT | STEPNAME | APPROVAL_NACHN | SIGNDATE |
---|---|---|---|---|
审批主键 | 审批单据编码 | 审批节点 | 审批人姓名 | 审批时间 |
1 | 1 | 节点1 | A | 2022-12-16 00:01:00 |
2 | 1 | 节点2 | B | 2022-12-16 01:01:00 |
3 | 1 | 节点2 | C | 2022-12-16 02:01:00 |
4 | 1 | 节点3 | D | 2022-12-16 02:10:00 |
5 | 1 | 节点1 | A | 2022-12-16 03:01:00 |
6 | 1 | 节点2 | B | 2022-12-16 04:01:00 |
7 | 1 | 节点2 | C | 2022-12-16 05:01:00 |
8 | 1 | 节点3 | D | 2022-12-16 06:01:00 |
9 | 1 | 节点4 | E | 2022-12-16 07:01:00 |
10 | 2 | 审批1 | Z | 2022-12-16 00:01:00 |
11 | 2 | 审批2 | Y | 2022-12-16 01:01:00 |
12 | 2 | 审批3 | X | 2022-12-16 02:01:00 |
13 | 2 | 审批3 | W | 2022-12-16 04:01:00 |
14 | 2 | 审批4 | V | 2022-12-16 06:01:00 |
15 | 2 | 审批4 | U | 2022-12-16 08:01:00 |
16 | 2 | 审批4 | T | 2022-12-16 10:01:00 |
17 | 2 | 审批5 | S | 2022-12-16 11:01:00 |
18 | 3 | 开始 | M | 2022-12-16 12:01:00 |
19 | 3 | 1级审批人 | N | 2022-12-16 13:01:00 |
20 | 3 | 2级审批人 | P | 2022-12-16 14:01:00 |
21 | 3 | 3级审批人 | R | 2022-12-16 15:01:00 |
22 | 3 | 4级审批人 | C | 2022-12-16 16:01:00 |
23 | 3 | 5级审批人 | G | 2022-12-16 17:01:00 |
24 | 3 | 5级审批人 | H | 2022-12-16 18:01:00 |
25 | 3 | 5级审批人 | O | 2022-12-16 19:01:00 |
26 | 3 | 6级审批人 | L | 2022-12-16 19:30:00 |
27 | 3 | 1级审批人 | N | 2022-12-16 20:01:00 |
28 | 3 | 2级审批人 | P | 2022-12-16 20:50:00 |
29 | 3 | 3级审批人 | R | 2022-12-16 21:01:00 |
30 | 3 | 4级审批人 | C | 2022-12-16 22:01:00 |
31 | 3 | 5级审批人 | G | 2022-12-17 00:01:00 |
32 | 3 | 5级审批人 | H | 2022-12-17 08:01:00 |
33 | 3 | 5级审批人 | O | 2022-12-17 09:01:00 |
34 | 3 | 6级审批人 | L | 2022-12-17 11:01:00 |
35 | 3 | 7级审批人 | liming | 2022-12-17 12:01:00 |
36 | 3 | 7级审批人 | zhangsan | 2022-12-17 14:01:00 |
37 | 3 | 8级审批人 | wangwu | 2022-12-16 16:01:00 |
2、需求说明
由样例数据可以看出某次审批节点名称形式不一样。以列出来的三种为例。
表中审批时间为审批完成时间。现在需要计算每个审批人的开始审批时间。
以单据1为例,可以看出:
1、此单据经历了2轮审批;
2、此单据中存在节点2为会签节点。即需要两个人各自审批。节点2的开始审批时间即为节点1的审批时间;
3、节点3的开始审批时间应为两个节点2最大完成审批时间;
4、往后还经历了新一轮的审批。按照单据往下顺推计算审批开始时间即可。
3、SQL计算实现
处理思路:
由数据可以看出,单据审批可能进行多轮。多轮审批中还会存在会签节点,会签节点的每个审批人开始时间都应是一致。
不同的审批,审批节点名称格式不一致。不易直接利用。此处业务无法给出准确定义。只是可以观察看清。
由此:
1、先按照单据分组进行排序。把每个单据的审批全周期数据组织到一起。
2、再进行LAG操作。处理会签节点的问题。
3、使用DENSE_RANK计算审批日志排序值。
4、最后通过关联计算出来每次审批的审批开始时间。
优点:
1、逻辑简单粗暴,容易理解。
缺点:
1、简单意味着冗长,会导致代码非常长。
2、此种处理比较笨重。会签节点的审批人数会有限制。如果有增加。就需要新增LAG函数处理。
代码实现:
CREATE TABLE TEMP_STEP1 AS
SELECT T4."ID",
T4."INCIDENT",
T4."STEPNAME",
T4."APPROVAL_NACHN",
T4."SIGNDATE",
DENSE_RANK() OVER(PARTITION BY T4."INCIDENT" ORDER BY T4."RANK_NUM" ASC) AS "RANK_NUM"
FROM (SELECT T3."ID",
T3."INCIDENT",
T3."STEPNAME",
T3."APPROVAL_NACHN",
T3."SIGNDATE",
CASE
WHEN
T3."STEPNAME" != T3."STEPNAME_1" THEN T3."RANK_NUM"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" != T3."STEPNAME_2" THEN T3."RANK_NUM_1"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" != T3."STEPNAME_3" THEN T3."RANK_NUM_2"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" != T3."STEPNAME_4" THEN T3."RANK_NUM_3"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" != T3."STEPNAME_5" THEN T3."RANK_NUM_4"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" != T3."STEPNAME_6" THEN T3."RANK_NUM_5"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" != T3."STEPNAME_7" THEN T3."RANK_NUM_6"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" != T3."STEPNAME_8" THEN T3."RANK_NUM_7"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" != T3."STEPNAME_9" THEN T3."RANK_NUM_8"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" != T3."STEPNAME_10" THEN T3."RANK_NUM_9"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" != T3."STEPNAME_11" THEN T3."RANK_NUM_10"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" != T3."STEPNAME_12" THEN T3."RANK_NUM_11"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" != T3."STEPNAME_13" THEN T3."RANK_NUM_12"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" != T3."STEPNAME_14" THEN T3."RANK_NUM_13"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" != T3."STEPNAME_15" THEN T3."RANK_NUM_14"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" != T3."STEPNAME_16" THEN T3."RANK_NUM_15"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" != T3."STEPNAME_17" THEN T3."RANK_NUM_16"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" != T3."STEPNAME_18" THEN T3."RANK_NUM_17"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" != T3."STEPNAME_19" THEN T3."RANK_NUM_18"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" != T3."STEPNAME_20" THEN T3."RANK_NUM_19"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" != T3."STEPNAME_21" THEN T3."RANK_NUM_20"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" != T3."STEPNAME_22" THEN T3."RANK_NUM_21"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" != T3."STEPNAME_23" THEN T3."RANK_NUM_22"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" != T3."STEPNAME_24" THEN T3."RANK_NUM_23"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" != T3."STEPNAME_25" THEN T3."RANK_NUM_24"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" != T3."STEPNAME_26" THEN T3."RANK_NUM_25"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" != T3."STEPNAME_27" THEN T3."RANK_NUM_26"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" != T3."STEPNAME_28" THEN T3."RANK_NUM_27"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" != T3."STEPNAME_29" THEN T3."RANK_NUM_28"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" != T3."STEPNAME_30" THEN T3."RANK_NUM_29"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" != T3."STEPNAME_31" THEN T3."RANK_NUM_30"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" != T3."STEPNAME_32" THEN T3."RANK_NUM_31"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" != T3."STEPNAME_33" THEN T3."RANK_NUM_32"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" != T3."STEPNAME_34" THEN T3."RANK_NUM_33"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" != T3."STEPNAME_35" THEN T3."RANK_NUM_34"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" != T3."STEPNAME_36" THEN T3."RANK_NUM_35"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" != T3."STEPNAME_37" THEN T3."RANK_NUM_36"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" = T3."STEPNAME_37"
AND T3."STEPNAME" != T3."STEPNAME_38" THEN T3."RANK_NUM_37"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" = T3."STEPNAME_37"
AND T3."STEPNAME" = T3."STEPNAME_38" AND T3."STEPNAME" != T3."STEPNAME_39" THEN T3."RANK_NUM_38"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" = T3."STEPNAME_37"
AND T3."STEPNAME" = T3."STEPNAME_38" AND T3."STEPNAME" = T3."STEPNAME_39"
AND T3."STEPNAME" != T3."STEPNAME_40" THEN T3."RANK_NUM_39"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" = T3."STEPNAME_37"
AND T3."STEPNAME" = T3."STEPNAME_38" AND T3."STEPNAME" = T3."STEPNAME_39"
AND T3."STEPNAME" = T3."STEPNAME_40" AND T3."STEPNAME" != T3."STEPNAME_41" THEN T3."RANK_NUM_40"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" = T3."STEPNAME_37"
AND T3."STEPNAME" = T3."STEPNAME_38" AND T3."STEPNAME" = T3."STEPNAME_39"
AND T3."STEPNAME" = T3."STEPNAME_40" AND T3."STEPNAME" = T3."STEPNAME_41"
AND T3."STEPNAME" != T3."STEPNAME_42" THEN T3."RANK_NUM_41"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" = T3."STEPNAME_37"
AND T3."STEPNAME" = T3."STEPNAME_38" AND T3."STEPNAME" = T3."STEPNAME_39"
AND T3."STEPNAME" = T3."STEPNAME_40" AND T3."STEPNAME" = T3."STEPNAME_41"
AND T3."STEPNAME" = T3."STEPNAME_42" AND T3."STEPNAME" != T3."STEPNAME_43" THEN T3."RANK_NUM_42"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" = T3."STEPNAME_37"
AND T3."STEPNAME" = T3."STEPNAME_38" AND T3."STEPNAME" = T3."STEPNAME_39"
AND T3."STEPNAME" = T3."STEPNAME_40" AND T3."STEPNAME" = T3."STEPNAME_41"
AND T3."STEPNAME" = T3."STEPNAME_42" AND T3."STEPNAME" = T3."STEPNAME_43"
AND T3."STEPNAME" != T3."STEPNAME_44" THEN T3."RANK_NUM_43"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" = T3."STEPNAME_37"
AND T3."STEPNAME" = T3."STEPNAME_38" AND T3."STEPNAME" = T3."STEPNAME_39"
AND T3."STEPNAME" = T3."STEPNAME_40" AND T3."STEPNAME" = T3."STEPNAME_41"
AND T3."STEPNAME" = T3."STEPNAME_42" AND T3."STEPNAME" = T3."STEPNAME_43"
AND T3."STEPNAME" = T3."STEPNAME_44" AND T3."STEPNAME" != T3."STEPNAME_45" THEN T3."RANK_NUM_44"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" = T3."STEPNAME_37"
AND T3."STEPNAME" = T3."STEPNAME_38" AND T3."STEPNAME" = T3."STEPNAME_39"
AND T3."STEPNAME" = T3."STEPNAME_40" AND T3."STEPNAME" = T3."STEPNAME_41"
AND T3."STEPNAME" = T3."STEPNAME_42" AND T3."STEPNAME" = T3."STEPNAME_43"
AND T3."STEPNAME" = T3."STEPNAME_44" AND T3."STEPNAME" = T3."STEPNAME_45"
AND T3."STEPNAME" != T3."STEPNAME_46" THEN T3."RANK_NUM_45"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" = T3."STEPNAME_37"
AND T3."STEPNAME" = T3."STEPNAME_38" AND T3."STEPNAME" = T3."STEPNAME_39"
AND T3."STEPNAME" = T3."STEPNAME_40" AND T3."STEPNAME" = T3."STEPNAME_41"
AND T3."STEPNAME" = T3."STEPNAME_42" AND T3."STEPNAME" = T3."STEPNAME_43"
AND T3."STEPNAME" = T3."STEPNAME_44" AND T3."STEPNAME" = T3."STEPNAME_45"
AND T3."STEPNAME" = T3."STEPNAME_46" AND T3."STEPNAME" != T3."STEPNAME_47" THEN T3."RANK_NUM_46"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" = T3."STEPNAME_37"
AND T3."STEPNAME" = T3."STEPNAME_38" AND T3."STEPNAME" = T3."STEPNAME_39"
AND T3."STEPNAME" = T3."STEPNAME_40" AND T3."STEPNAME" = T3."STEPNAME_41"
AND T3."STEPNAME" = T3."STEPNAME_42" AND T3."STEPNAME" = T3."STEPNAME_43"
AND T3."STEPNAME" = T3."STEPNAME_44" AND T3."STEPNAME" = T3."STEPNAME_45"
AND T3."STEPNAME" = T3."STEPNAME_46" AND T3."STEPNAME" = T3."STEPNAME_47"
AND T3."STEPNAME" != T3."STEPNAME_48" THEN T3."RANK_NUM_47"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" = T3."STEPNAME_37"
AND T3."STEPNAME" = T3."STEPNAME_38" AND T3."STEPNAME" = T3."STEPNAME_39"
AND T3."STEPNAME" = T3."STEPNAME_40" AND T3."STEPNAME" = T3."STEPNAME_41"
AND T3."STEPNAME" = T3."STEPNAME_42" AND T3."STEPNAME" = T3."STEPNAME_43"
AND T3."STEPNAME" = T3."STEPNAME_44" AND T3."STEPNAME" = T3."STEPNAME_45"
AND T3."STEPNAME" = T3."STEPNAME_46" AND T3."STEPNAME" = T3."STEPNAME_47"
AND T3."STEPNAME" = T3."STEPNAME_48" AND T3."STEPNAME" != T3."STEPNAME_49" THEN T3."RANK_NUM_48"
WHEN
T3."STEPNAME" = T3."STEPNAME_1"
AND T3."STEPNAME" = T3."STEPNAME_2" AND T3."STEPNAME" = T3."STEPNAME_3"
AND T3."STEPNAME" = T3."STEPNAME_4" AND T3."STEPNAME" = T3."STEPNAME_5"
AND T3."STEPNAME" = T3."STEPNAME_6" AND T3."STEPNAME" = T3."STEPNAME_7"
AND T3."STEPNAME" = T3."STEPNAME_8" AND T3."STEPNAME" = T3."STEPNAME_9"
AND T3."STEPNAME" = T3."STEPNAME_10" AND T3."STEPNAME" = T3."STEPNAME_11"
AND T3."STEPNAME" = T3."STEPNAME_12" AND T3."STEPNAME" = T3."STEPNAME_13"
AND T3."STEPNAME" = T3."STEPNAME_14" AND T3."STEPNAME" = T3."STEPNAME_15"
AND T3."STEPNAME" = T3."STEPNAME_16" AND T3."STEPNAME" = T3."STEPNAME_17"
AND T3."STEPNAME" = T3."STEPNAME_18" AND T3."STEPNAME" = T3."STEPNAME_19"
AND T3."STEPNAME" = T3."STEPNAME_20" AND T3."STEPNAME" = T3."STEPNAME_21"
AND T3."STEPNAME" = T3."STEPNAME_22" AND T3."STEPNAME" = T3."STEPNAME_23"
AND T3."STEPNAME" = T3."STEPNAME_24" AND T3."STEPNAME" = T3."STEPNAME_25"
AND T3."STEPNAME" = T3."STEPNAME_26" AND T3."STEPNAME" = T3."STEPNAME_27"
AND T3."STEPNAME" = T3."STEPNAME_28" AND T3."STEPNAME" = T3."STEPNAME_29"
AND T3."STEPNAME" = T3."STEPNAME_30" AND T3."STEPNAME" = T3."STEPNAME_31"
AND T3."STEPNAME" = T3."STEPNAME_32" AND T3."STEPNAME" = T3."STEPNAME_33"
AND T3."STEPNAME" = T3."STEPNAME_34" AND T3."STEPNAME" = T3."STEPNAME_35"
AND T3."STEPNAME" = T3."STEPNAME_36" AND T3."STEPNAME" = T3."STEPNAME_37"
AND T3."STEPNAME" = T3."STEPNAME_38" AND T3."STEPNAME" = T3."STEPNAME_39"
AND T3."STEPNAME" = T3."STEPNAME_40" AND T3."STEPNAME" = T3."STEPNAME_41"
AND T3."STEPNAME" = T3."STEPNAME_42" AND T3."STEPNAME" = T3."STEPNAME_43"
AND T3."STEPNAME" = T3."STEPNAME_44" AND T3."STEPNAME" = T3."STEPNAME_45"
AND T3."STEPNAME" = T3."STEPNAME_46" AND T3."STEPNAME" = T3."STEPNAME_47"
AND T3."STEPNAME" = T3."STEPNAME_48" AND T3."STEPNAME" = T3."STEPNAME_49"
AND T3."STEPNAME" != T3."STEPNAME_50" THEN T3."RANK_NUM_49"
ELSE T3."RANK_NUM_50" END AS "RANK_NUM"
FROM (SELECT T2."ID",
T2."INCIDENT",
T2."STEPNAME",
T2."APPROVAL_NACHN",
T2."SIGNDATE",
T2."RANK_NUM",
LAG(T2."STEPNAME", 1, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_1",
LAG(T2."RANK_NUM", 1, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_1",
LAG(T2."STEPNAME", 2, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_2",
LAG(T2."RANK_NUM", 2, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_2",
LAG(T2."STEPNAME", 3, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_3",
LAG(T2."RANK_NUM", 3, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_3",
LAG(T2."STEPNAME", 4, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_4",
LAG(T2."RANK_NUM", 4, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_4",
LAG(T2."STEPNAME", 5, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_5",
LAG(T2."RANK_NUM", 5, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_5",
LAG(T2."STEPNAME", 6, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_6",
LAG(T2."RANK_NUM", 6, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_6",
LAG(T2."STEPNAME", 7, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_7",
LAG(T2."RANK_NUM", 7, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_7",
LAG(T2."STEPNAME", 8, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_8",
LAG(T2."RANK_NUM", 8, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_8",
LAG(T2."STEPNAME", 9, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_9",
LAG(T2."RANK_NUM", 9, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_9",
LAG(T2."STEPNAME", 10, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_10",
LAG(T2."RANK_NUM", 10, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_10",
LAG(T2."STEPNAME", 11, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_11",
LAG(T2."RANK_NUM", 11, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_11",
LAG(T2."STEPNAME", 12, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_12",
LAG(T2."RANK_NUM", 12, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_12",
LAG(T2."STEPNAME", 13, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_13",
LAG(T2."RANK_NUM", 13, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_13",
LAG(T2."STEPNAME", 14, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_14",
LAG(T2."RANK_NUM", 14, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_14",
LAG(T2."STEPNAME", 15, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_15",
LAG(T2."RANK_NUM", 15, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_15",
LAG(T2."STEPNAME", 16, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_16",
LAG(T2."RANK_NUM", 16, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_16",
LAG(T2."STEPNAME", 17, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_17",
LAG(T2."RANK_NUM", 17, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_17",
LAG(T2."STEPNAME", 18, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_18",
LAG(T2."RANK_NUM", 18, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_18",
LAG(T2."STEPNAME", 19, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_19",
LAG(T2."RANK_NUM", 19, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_19",
LAG(T2."STEPNAME", 20, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_20",
LAG(T2."RANK_NUM", 20, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_20",
LAG(T2."STEPNAME", 21, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_21",
LAG(T2."RANK_NUM", 21, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_21",
LAG(T2."STEPNAME", 22, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_22",
LAG(T2."RANK_NUM", 22, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_22",
LAG(T2."STEPNAME", 23, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_23",
LAG(T2."RANK_NUM", 23, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_23",
LAG(T2."STEPNAME", 24, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_24",
LAG(T2."RANK_NUM", 24, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_24",
LAG(T2."STEPNAME", 25, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_25",
LAG(T2."RANK_NUM", 25, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_25",
LAG(T2."STEPNAME", 26, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_26",
LAG(T2."RANK_NUM", 26, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_26",
LAG(T2."STEPNAME", 27, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_27",
LAG(T2."RANK_NUM", 27, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_27",
LAG(T2."STEPNAME", 28, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_28",
LAG(T2."RANK_NUM", 28, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_28",
LAG(T2."STEPNAME", 29, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_29",
LAG(T2."RANK_NUM", 29, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_29",
LAG(T2."STEPNAME", 30, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_30",
LAG(T2."RANK_NUM", 30, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_30",
LAG(T2."STEPNAME", 31, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_31",
LAG(T2."RANK_NUM", 31, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_31",
LAG(T2."STEPNAME", 32, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_32",
LAG(T2."RANK_NUM", 32, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_32",
LAG(T2."STEPNAME", 33, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_33",
LAG(T2."RANK_NUM", 33, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_33",
LAG(T2."STEPNAME", 34, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_34",
LAG(T2."RANK_NUM", 34, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_34",
LAG(T2."STEPNAME", 35, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_35",
LAG(T2."RANK_NUM", 35, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_35",
LAG(T2."STEPNAME", 36, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_36",
LAG(T2."RANK_NUM", 36, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_36",
LAG(T2."STEPNAME", 37, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_37",
LAG(T2."RANK_NUM", 37, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_37",
LAG(T2."STEPNAME", 38, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_38",
LAG(T2."RANK_NUM", 38, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_38",
LAG(T2."STEPNAME", 39, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_39",
LAG(T2."RANK_NUM", 39, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_39",
LAG(T2."STEPNAME", 40, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_40",
LAG(T2."RANK_NUM", 40, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_40",
LAG(T2."STEPNAME", 41, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_41",
LAG(T2."RANK_NUM", 41, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_41",
LAG(T2."STEPNAME", 42, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_42",
LAG(T2."RANK_NUM", 42, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_42",
LAG(T2."STEPNAME", 43, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_43",
LAG(T2."RANK_NUM", 43, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_43",
LAG(T2."STEPNAME", 44, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_44",
LAG(T2."RANK_NUM", 44, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_44",
LAG(T2."STEPNAME", 45, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_45",
LAG(T2."RANK_NUM", 45, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_45",
LAG(T2."STEPNAME", 46, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_46",
LAG(T2."RANK_NUM", 46, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_46",
LAG(T2."STEPNAME", 47, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_47",
LAG(T2."RANK_NUM", 47, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_47",
LAG(T2."STEPNAME", 48, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_48",
LAG(T2."RANK_NUM", 48, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_48",
LAG(T2."STEPNAME", 49, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_49",
LAG(T2."RANK_NUM", 49, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_49",
LAG(T2."STEPNAME", 50, '') OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "STEPNAME_50",
LAG(T2."RANK_NUM", 50, 0) OVER(PARTITION BY T2."INCIDENT" ORDER BY T2."SIGNDATE" ASC) AS "RANK_NUM_50"
FROM (SELECT T1."ID",
T1."INCIDENT",
T1."STEPNAME",
T1."APPROVAL_NACHN",
T1."SIGNDATE",
ROW_NUMBER() OVER(PARTITION BY T1."INCIDENT" ORDER BY T1."SIGNDATE" ASC) AS "RANK_NUM"
FROM (SELECT T."ID",
T."INCIDENT",
T."STEPNAME",
T."APPROVAL_NACHN",
T."SIGNDATE"
FROM APPROVAL_LOG T) T1) T2) T3) T4;
-- 结果 START_DATE
SELECT T1."ID",
T1."INCIDENT",
T1."STEPNAME",
T1."APPROVAL_NACHN",
T1."SIGNDATE",
T2."START_DATE"
FROM (SELECT "ID",
"INCIDENT",
"STEPNAME",
"APPROVAL_NACHN",
"SIGNDATE",
"RANK_NUM"
FROM TEMP_STEP1) T1
LEFT JOIN (SELECT "INCIDENT",
"RANK_NUM",
MAX("SIGNDATE") AS "START_DATE"
FROM TEMP_STEP1
GROUP BY "INCIDENT",
"RANK_NUM") T2
ON T1."INCIDENT" = T2."INCIDENT"
AND T1."RANK_NUM" = T2."RANK_NUM" + 1;
4、来自大厂的大神SQL实现
SELECT T1."ID",
T1."INCIDENT",
T1."STEPNAME",
T1."APPROVAL_NACHN",
T1."SIGNDATE",
MIN(T1."LAG_SIGNDATE") OVER(PARTITION BY T1."INCIDENT", T1."STEPNAME", T1."RANK_NUM" - T1."RANK_NUM_NODE") AS "START_DATE"
FROM (SELECT T."ID",
T."INCIDENT",
T."STEPNAME",
T."APPROVAL_NACHN",
T."SIGNDATE",
ROW_NUMBER() OVER(PARTITION BY T."INCIDENT" ORDER BY T1."SIGNDATE" ASC) AS "RANK_NUM",
ROW_NUMBER() OVER(PARTITION BY T."INCIDENT", T1."STEPNAME" ORDER BY T1."SIGNDATE" ASC) AS "RANK_NUM_NODE",
LAG(T1."SIGNDATE", 1, '') OVER(PARTITION BY T1."INCIDENT" ORDER BY T1."SIGNDATE" ASC) AS "LAG_SIGNDATE"
FROM APPROVAL_LOG T) T1;