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

The Archive Base Latest Questions

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

I have a table in which all the records have an id, timestamp, and

  • 0

I have a table in which all the records have an id, timestamp, and a Boolean value. I need to discover in which records the Boolean changes to false within 1 second of it being true for the same id.

I’ve been working on the following statement, but after doing some research, I feel either a CASE combined with a FETCH statement might work better, but I haven’t found a good example where they’ve been used together.

SELECT *  
FROM Table_1  
WHERE timestamp IN(  
    SELECT DATEADD(Second, 1, timestamp)  
    from Table_1  
    where Boolean = 1)  
AND ID in (  
    SELECT ID   
    from Table_1 where Boolean = 1)  
AND Boolean = 0
  • 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-13T14:27:51+00:00Added an answer on June 13, 2026 at 2:27 pm

    How about:

    Select Distinct
      t1.id
    From
      Table_1 t1
        Inner Join
      Table_1 t2
        On
          t1.Id = t2.Id And 
          t1.Boolean = True And 
          t2.Boolean = False And
          DateDiff(Second, t1.Timestamp, t2.Timestamp) Between 0 And 1
    

    a matter of taste as to how much of that you put in the join clause and how much you put into a where clause.

    Edits

    • added distinct
    • put minimum bound on date difference
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table which records all field changes in all database tables
I have web page in PHP which displays all records in a table. I
I have a simple table view which is editable. All I need the user
I have a logins table which records all login and logout activities. I want
I have one procedure which retrieves all the records from one table which has
I have a draggable table which all working fine, though I want to be
I have multiple buttons that gets created in a table which all look like
I have a table which i want to store all the outputs into one
I have a table named tbl_Subjects_Taken which lists all the subjects taken by the
I have a table called TPM_TASKS which contain all tasks, as well as a

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.