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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:58:24+00:00 2026-06-15T23:58:24+00:00

i am using the below query to find the null values of a column

  • 0

i am using the below query to find the null values of a column and get the starttime and endtime of the null values using the below query for some 30,000 rows

    SELECT
    yt1.[timestamp] AS StartTime,
    MIN(yt2.[timestamp]) AS EndTime,
    DATEDIFF(MINUTE, yt1.[timestamp], MIN(yt2.[timestamp])) AS DifferenceInMinutes
    FROM
    Sheet1$ yt1
    LEFT JOIN Sheet1$ yt2 ON yt1.[timestamp] < yt2.[timestamp]
    WHERE
    yt1.TWSPD IS NULL
    GROUP BY yt1.[timestamp]

The output is

Start time                     Endtime                DifferenceInMinutes
2012-05-18 20:47:03.000    2012-05-18 20:57:04.000      10
2012-05-18 20:57:04.000    2012-05-18 21:07:04.000      10
2012-05-21 18:25:26.000    2012-05-21 18:35:26.000      10
2012-06-07 17:36:28.000    2012-06-07 17:46:28.000      10
2012-06-07 17:46:28.000    2012-06-07 17:56:28.000      10
2012-06-07 17:56:28.000    2012-06-07 18:06:28.000      10

And for example now i need the output as (removed some row to display better)

Start time                     Endtime                DifferenceInMinutes
2012-05-18 20:47:03.000    2012-05-18 21:07:04.000      20
2012-05-21 18:25:26.000    2012-05-21 18:35:26.000      10
2012-06-07 17:36:28.000    2012-06-07 18:06:28.000      30

The timestamp is for every 10 min, if the null values for consecutive 10min timegap should be added and the starttime and endtime should be displayed as from the first null to last null of consecutive timestamp. Hope the question is clear. Please let me know if i am not clear. Please help

  • 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-15T23:58:24+00:00Added an answer on June 15, 2026 at 11:58 pm
     SELECT
        yt1.[timestamp] AS StartTime,
        MIN(yt2.[timestamp]) AS EndTime,
        DATEDIFF(MINUTE, yt1.[timestamp], MIN(yt2.[timestamp])) AS DifferenceInMinutes
        into #tmp1
        FROM
        Sheet1$ yt1
        LEFT JOIN Sheet1$ yt2 ON yt1.[timestamp] < yt2.[timestamp]
        WHERE
        yt1.TWSPD IS NULL
        GROUP BY yt1.[timestamp]
    
    
    Select t1.* 
    into #tmp2
    from #tmp1 t1
    left join #tmp1 t2 on t1.Starttime=t2.Endtime
    where t2.Endtime is null
    
    Declare @rcn int
    Select @rcn=1
    While @rcn>0
        begin
           Update #tmp2 set #tmp2.Endtime=t.endTime,#tmp2.DifferenceInMinutes=#tmp2.DifferenceInMinutes+t.DifferenceInMinutes
           from #tmp1 t
           where t.Starttime=#tmp2.Endtime
           select @rcn=@@Rowcount
        end
    
    
    select * from #tmp2
    
    Drop Table #tmp1
    Drop Table #tmp2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using below mentioned query with about 400,000 records in each table its taking
Using a query like below you can fetch rows in which the color of
I'm populating my select box using the query shown below: <%=f.select :acoustic, options_for_select(User.includes(:roles).where( :roles
I'm using below query to count the daily result, but now I'm make it
I am using the below query to return the names of artists which appear
I'm using Sql-Server, and I have the below query which returns all columns that
We have the query below. Using a LEFT OUTER join takes 9 seconds to
I am using SQL Query and below are the tables. Organization OrgID Name RAOGID
I am using SQL Query and below are the tables. Organization OrgID Name RAOGID
I am using SQL Query and below are the tables. Organization OrgID Name RAOID

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.