数据已在## YOMASTER(临时表)中托管,我正在使用我的Water Fall Logic上的更新。
当前水落逻辑具有3个组件并且它们共享以下内容:将使用哪个日期,然后将日期及其字段名称插入以下2个字段> StatusCode位置& StartClockDt2字段
:::第1阶段:::
> If Date Found on Step 1 then use that date. (Else use Phase 3)
> If No Date found on Step 1 then Move to Step 2 (Else use Phase 3)
> If No Date found on Step 2 then Move to Step 3 (Else use Phase 3)
> If No Date found on Step 3 then Move to Step 4 (Else use Phase 3)
> If No Date found on Step 4 then Move to Step 5 (Else use Phase 3)
> If No Date found on Step 5 then Move to Step 6
:::第2阶段:::
> If Dates Found on Step 2 and 3 then choose the one with the Max Date
:::第3阶段:::
> If Step 6 Shows the Max Date out of all other Steps, then Use that Date and apply it to StatusCode Location & StartClockDt2 Fields.
注意:逻辑的第一阶段工作,我只需要查询来处理第2阶段和第3阶段。
以下是第一阶段使用的当前代码。
UPDATE ##YOMASTER
SET StatusCodeLocation='No Date',StartClockDt2 = Null
UPDATE ##YOMASTER
SET StatusCodeLocation='Uno', StartClockDt2=Uno
WHERE Uno is not null
UPDATE ##YOMASTER
SET StatusCodeLocation='Dos', StartClockDt2=Dos
WHERE Dos is not null and StartClockDt2 is null
UPDATE ##YOMASTER
SET StatusCodeLocation='Tres', StartClockDt2=Tres
WHERE Tres is not null and StartClockDt2 is null
UPDATE ##YOMASTER
SET StatusCodeLocation='Cuatro', StartClockDt2=Cuatro
WHERE Cuatro is not null and StartClockDt2 is null
UPDATE ##YOMASTER
SET StatusCodeLocation='Cinco', StartClockDt2=Cinco
WHERE Cinco is not null and StartClockDt2 is null
UPDATE ##YOMASTER
SET StatusCodeLocation='Seis', StartClockDt2=Seis
WHERE Seis is not null and StartClockDt2 is null
UPDATE ##YOMASTER
SET StartClockDt2=null
WHERE statuscodelocation='No Date'