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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:05:22+00:00 2026-05-26T04:05:22+00:00

I have the following data: ID Date interval interval_date tot_activity non-activity 22190 2011-09-27 00:00:00

  • 0

I have the following data:

ID       Date                 interval  interval_date            tot_activity  non-activity
22190   2011-09-27 00:00:00     1000    2011-09-27 10:00:00.000     265           15

I have another table with this data:

Date                        ID             Start                END               sched_non_activity     non_activity
10/3/2011 12:00:00 AM   HBLV-22267  10/3/2011 2:02:00 PM    10/3/2011 2:11:00 PM    540          

Now, in the second table’s non_activity field, I would like this to be the value from the first table. However, I need to capture the tot_activity – non_activity where the intervals(in 15 min increments) from the first table, fall in the same time frame as the start and end of the second table.

I have tried setting variables and setting a loop where for each row it verifies the starttime by interval, but I have no idea how to return a variable with only one record, as I keep getting errors that my variable is getting too many results.

I have tried looking everywhere for tutorials and I can’t find anything to help me out. Anyone have any pointers or tutorials on looping they could share?

  • 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-26T04:05:23+00:00Added an answer on May 26, 2026 at 4:05 am

    You need to generate the interval end dates somehow; I’m assuming that there is always a record in the first table with a 15 minute interval record. In this case, an example would look like this:

    ;WITH Intervals
    AS
    (SELECT
         Interval_date
         ,DATEADD(ms,840997,Interval_date) AS interval_end
        ,nonactivity
    FROM A)
    
    --Select query for Validation
    --SELECT 
    --  b.[Date]
    --  ,b.ID 
    --  ,b.Start
    --  ,b.sched_non_activity
    --  ,i.nonactivity
    --FROM B
    --JOIN Intervals AS i
    --ON b.Start >= i.Interval_date 
    --AND b.[END] <= i.interval_end 
    
    UPDATE B
        SET non_activity = i.nonactivity
    FROM  B
    JOIN Intervals AS i
    ON b.Start >= i.Interval_date   
    AND b.[END] <= i.interval_end   
    

    Obviously, you might need to tweak this depending on the exact circumstances.

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

Sidebar

Related Questions

I have the following data: cust subject date Cust1 Subject1 2010-12-31 21:59:59.000 Cust1 Subject1
I have the following data Date Week ID Tot_Seconds O_Seconds Week_ID 8/14/2011 12:00:00 AM
I have the following data set structure: date time_in_hours price Sep 03 08 9.76
I have following data frames > head(elo) date elo 1 1921-12-18 1597 2 1922-05-14
I have the following data on a table tbl Admission : Date and Time
I have the following data | Item | Value | Date | ------------------------------ |
I have a table with the following data: id | numbers | date ----------------------------------
I have data like the following: var data = [{ id: 1, date: new
I have multiple data entries that contain the following information: id_number name1 date name2
I have the following data in my table: id invoice_id date ammount 1 1

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.