1

数据托管在##YOMASTER(临时表)中,我正在使用我的瀑布逻辑更新。

当前的瀑布逻辑有 3 个组件,它们都共享以下内容:要使用哪个日期,然后将此类日期及其字段名称插入以下 2 个字段> StatusCode Location & StartClockDt2 Fields

::: 阶段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

:::第三阶段:::

> 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'
4

0 回答 0