Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7979995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:56:01+00:00 2026-06-04T09:56:01+00:00

Only Teradata SQL is available for use. I’m trying to dynamically create a list

  • 0

Only Teradata SQL is available for use.

I’m trying to dynamically create a list of dates on which give jobs will run. Here is a simplified version of what I’m dealing with.

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

Logic done through a case statement in the select

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

However, when the run_flag = ‘Y’ and the Holiday_Flag = 1 then the job should be listed to run on the next Business/Calendar day (depending on the day_type).

I think I need to use a lead/lag but I don’t know if I can get it to run through the logic involved.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:56:03+00:00Added an answer on June 4, 2026 at 9:56 am

    Try this:

    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
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I only have focused on making apps for apps that will be installed on
Only a few people recommended to use Sphinx at the beginning of the year.
The only one I can find is the BoundedFIFOBuffer, which is deprecated. Any others?
Only for tutorial purpose, I would like to try to use a free SOAP
I only want a list of files that have been added (not ones that
Only for MSSQL 2000-2005 by SQL query and no stored procedures No cursors and
I'm trying to load a table, create an index, collect statistics, grant select permissions
In Teradata DB I have source table create set table SRC_TABLE ( Some_Id varchar(2O)
My only experience with Machine Learning / Data Mining is via SQL Server Analysis
Only one instance of a Script Manager can be added to the page. Such

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.