0

Teradata SQL のみを使用できます。

特定のジョブが実行される日付のリストを動的に作成しようとしています。これは、私が扱っているものの簡略化されたバージョンです。

Calendar (covers 2012+)
--------
Calender Date
Business Day Flag - 1 = This is a Business Day, 0 = Weekend
Holiday Flag - 1 = This is a Holiday, 0 = Non-Holiday
Year
Month
Day

Schedule (several more fields available, but not relevant)
--------
Day Type - Business Day or Calendar Date
Day Number - Represents either a Business or Calendar Day
Eligible to run on holiday - Yes / No

select の case ステートメントを介して実行されるロジック

when d.day_type = 'BD' and day_num = c.business_day_of_month  then 'Y'
when d.day_type = 'CD' and day_num = c.day_of_month then 'Y'
else 'N' as run_flag

ただし、run_flag = 'Y' および Holiday_Flag = 1 の場合、次の営業日/カレンダー日に実行するようにジョブをリストする必要があります (day_type によって異なります)。

リード/ラグを使用する必要があると思いますが、関連するロジックを実行できるかどうかわかりません。

何か案は?

4

1 に答える 1

1

これを試して:

select
    a.calendar_dt,
    min(b.dt) as next_business_dt
from my_calendar a
cross join my_calendar b
where a.calendar_dt < b.calendar_dt
and b.business_day_flag = 1
and b.holiday_flag = 0
group by
    a.calendar_dt
于 2012-05-23T00:02:47.033 に答える