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 9157861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:07:13+00:00 2026-06-17T13:07:13+00:00

Am having a brain freeze… I have 4 status dates i.e. when the status

  • 0

Am having a brain freeze…

I have 4 status dates i.e. when the status was changed on a client record and I need to then query the data and find at what status the client was at a particular date.

e.g. Data

Client Setup Date Live Date Closing Date Closed Date

0001 01/01/12 10/01/12 23/02/12 15/11/12

0002 08/10/12 11/11/12

0003 11/12/12

So for a date of 31/12/12 then 0001 would indicate a status of closed, 0002 would be Live, 0003 would be Setup.

I want to return only the Client and Status for that date.

So on 31/12/12 I would get a result of
0001 Closed
0002 Live
0003 Setup

I tried this using a case but it’s gone wrong somewhere as it seems to be returning me the same status and I can see why it doesn’t work but my little noggin can’t work out a way to get it to work. This is coming from another query that extracts and inserts into a #Temp table.

CASE 
WHEN #TempOutput.[System Setup] BETWEEN @Start and @End THEN 'Prospect' 
WHEN #TempOutput.[Prospect to Live] BETWEEN @Start and @End THEN 'Live'
WHEN #TempOutput.[Live to Terminal] BETWEEN @Start and @End THEN 'Terminal'
WHEN #TempOutput.Closing BETWEEN @Start and @End THEN 'Closed'
END 

This is like the first step as I then need to loop through this to show what the status was of each client over a period. So if it’s a weekly period then it needs to loop through 52 times based on an entry date… I can do this bit! LOL

any help 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-06-17T13:07:14+00:00Added an answer on June 17, 2026 at 1:07 pm
    SELECT Client,
    CASE 
       WHEN [Closed] <= @GivenDate THEN 'Closed'
       WHEN [Closing] <= @GivenDate THEN 'Closing'
       WHEN [Live to Terminal] <= @GivenDate THEN 'Terminal'
       WHEN [Prospect to Live] <= @GivenDate THEN 'Live'
       ELSE 'Prospect' 
    END Status
    FROM #TempOutput
    WHERE [System Setup] <= @GivenDate
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ok, I must be having a brain freeze here... I have a ComboBox with
Having a major brain freeze, I have the following chunk of code: // Get
I have done this before but seem to be having a brain freeze and
I am having a brain-cease on a data problem that I am in need
Having a bit of a brain freeze on how to do this. I have
Having a brain freeze on how best to approach this, I have a ton
Having a brain freeze over a fairly trivial problem. If I start with an
I'm new to jquery and, in addition, I think I'm having a brain freeze.
I'm having a bit of a brain-freeze so I thought I'd throw this out
Ok, I guess I'm having a brain fart here and cant find my way

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.