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

  • Home
  • SEARCH
  • 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 989389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:47:05+00:00 2026-05-16T05:47:05+00:00

this one has me stuck fast. Data: Month Total Impact Forecast ———————————————— 2010-04-01 45792.0000

  • 0

this one has me stuck fast.

Data:

Month           Total         Impact    Forecast
------------------------------------------------
2010-04-01    45792.0000    1.0000    NULL
2010-05-01    51789.0000    1.0000    NULL
2010-06-01    58228.0000    1.0000    NULL
2010-07-01    52956.5217    1.0000    NULL
2010-08-01    53600.4700    0.8810    NULL
2010-09-01    54257.8784    1.1838    NULL
2010-10-01    55134.0669    1.0000    NULL 

Now what I’m trying to do is loop through the current contents of the table and update the Forecast column using conditional IF statements as follows:

If Impact = 1.0000 then forecast = (current month) total * Impact
If Impact < 1.0000 then forecast = (month -1) total * Impact
If Impact > 1.0000 then forecast = (month -2) total * Impact

I did think of using the CASE statement though calculating the forecast using previous dates stumped me, I presume I will need to utilise a while statements and RBAR.

Much appreciated.

  • 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-05-16T05:47:06+00:00Added an answer on May 16, 2026 at 5:47 am

    How about this:

    UPDATE [Table]
    SET
        [Forecast] = [Impact] * CASE
            WHEN [Impact] = 1.0000 THEN
            (
                SELECT
                    [InnerTable].[Total]
                FROM [Table] AS [InnerTable]
                WHERE [InnerTable].[Month] = [Table].[Month]
            )
            WHEN [Impact] < 1.0000 THEN
            (
                SELECT
                    [InnerTable].[Total]
                FROM [Table] AS [InnerTable]
                WHERE [InnerTable].[Month] = DATEADD(month, -1, [Table].[Month])
            )
            ELSE
            (
                SELECT
                    [InnerTable].[Total]
                FROM [Table] AS [InnerTable]
                WHERE [InnerTable].[Month] = DATEADD(month, -2, [Table].[Month])
            )
        END    
    FROM [Table]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It's amazing how fast you start using this framework, but i'm stuck on one
This one has me pretty rattled so I thank you in advance for your
This one has been stumping me for a while. But I'm no expert. This
This one has me scratching my head, so I'm hoping a second pair of
This one has proven to be a little tricky for me so far. I
This one has me stumped. <div id=container> <div id=store></div> <div id=contact></div> </div> I'm looking
This one has me stumped. Here are the relative bits of code: public AgencyDetails(Guid
This one has made me a lot of stress over the last couple of
This one has me stumped. I need to call an activity method from within
I know this one has been asked few times already ( 1 , 2

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.