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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:27:26+00:00 2026-06-13T04:27:26+00:00

Okay, so I have a question about using columns in a case statement that

  • 0

Okay, so I have a question about using columns in a case statement that might be null.

Again I have two tables the first looks like this UserActivity:

   userID    Action    Time
     1         25       12:00
     1         10       12:01
     1         12       12:35
     1          6       13:54
     2         10        6:47
     2         42        6:48
     3          8       11:54
     etc.

But the second now looks like this UserSchedule:

   userID      startTime1        stopTime1     startTime2    stoptime2  startTime3    stopTime3
     1            07:00            09:00         11:00         12:00       14:30         16:30
     2            11:00            12:30         14:00         15:30       
     3            14:00            15:00
    etc.

So I need to be able to evaluate when in relation to all of those start and stop times an Action took place. Some users will have up to 5 start/stop times in a day. Some will only have one.

This code was given to me to resolve an earlier issue by @Adam Wengler, and it works great if there is only one start and stop time. I’m unsure how to include the logic to test against each of the 5 potential start/stop columns and ignore them if they are empty.

  UPDATE ua
  SET ua.TimeStatusId = CASE
                    WHEN ua.Time >= us.Schedule_Start
                       AND ua.Time <= us.Schedule_stop THEN 1
                    WHEN ua.Time >= DATEADD(HOUR, -1, us.Schedule_Start)
                       AND ua.Time <= us.ScheduleStart THEN 0
                    WHEN ua.Time >= us.Schedule_Stop
                       AND ua.Time =< DATEADD(HOUR, 1, us.Schedule_Stop)
                       THEN 2
                    ELSE 3
                  END
  FROM dbo.UserActivity AS ua
  INNER JOIN dbo.userSchedule AS us ON ua.UserId = us.UserId
  • 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-13T04:27:27+00:00Added an answer on June 13, 2026 at 4:27 am

    You can use the IsNull() function to resolve your issue

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay guys I have a question about positioning tables within DIV's using CSS. I
Okay, next PHPExcel question. I have an HTML form that users fill out and
QUESTION: Is it okay to have shortcut identifiers in a table so that I
I have a question about using os.execvp in Python. I have the following bit
Okay, so I have another question on a prolog homework problem I am struggling
Okay, newbie multi-threading question: I have a Singleton class. The class has a Static
Okay this question is very simple: I have a facebook page, and a website.
Okay this may be a simple question but I have yet to come with
Okay I edit my question, try to explain it more clearly: I have a
Okay guys, I have read through all the other posts and question on jQuery

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.