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 55719

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:25:17+00:00 2026-05-10T17:25:17+00:00

I have a database issue that i currently cannot wrap my head around with

  • 0

I have a database issue that i currently cannot wrap my head around with an easy solution. In my db I have a table that stores event values.. 0’s and 1’s with a timestamp. Issue being that it is possible for there to be the same event to occur twice as a business rule. Like below

  • ‘2008-09-22 16:28:14.133’, 0
  • ‘2008-09-22 16:28:35.233’, 1
  • ‘2008-09-22 16:29:16.353’, 1
  • ‘2008-09-22 16:31:37.273’, 0
  • ‘2008-09-22 16:35:43.134’, 0
  • ‘2008-09-22 16:36:39.633’, 1
  • ‘2008-09-22 16:41:40.733’, 0

in real life these events are cycled and I’m trying to query over to get the cycles of these but I need to ignore the duplicate values ( 1,1 ) the current solution is using a SQL cursor to loop each and throw out the value if the previous was the same. I’ve considered using a trigger on the insert to clean up in a post processed table but I can’t think of an easy solution to do this set based.

Any ideas or suggestions?

Thanks

  • 0 0 Answers
  • 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. 2026-05-10T17:25:18+00:00Added an answer on May 10, 2026 at 5:25 pm

    This uses a SQL Server Common Table Expression, but it can be inlined, with table t with columns dt and cyclestate:

    ;WITH Firsts AS (     SELECT t1.dt         ,MIN(t2.dt) AS Prevdt     FROM t AS t1     INNER JOIN t AS t2         ON t1.dt < t2.dt         AND t2.cyclestate <> t1.cyclestate     GROUP BY t1.dt ) SELECT MIN(t1.dt) AS dt_start     ,t2.dt AS dt_end FROM t AS t1 INNER JOIN Firsts     ON t1.dt = Firsts.dt INNER JOIN t AS t2     ON t2.dt = Firsts.Prevdt     AND t1.cyclestate <> t2.cyclestate GROUP BY t2.dt     ,t2.cyclestate HAVING MIN(t1.cyclestate) = 0 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer My first response is that it's probably a mistake to… May 11, 2026 at 11:37 pm
  • Editorial Team
    Editorial Team added an answer There's no magic way to include jQuery. Since it's a… May 11, 2026 at 11:37 pm
  • Editorial Team
    Editorial Team added an answer if ((strlen($title) > 3) && (strlen($message) > 3)) I do… May 11, 2026 at 11:37 pm

Related Questions

Earlier this week I ask a question about filtering out duplicate values in sequence
Notes: Cannot use Javascript or iframes. In fact I can't trust the client browser
As usual, some background information first: Database A (Access database) - Holds a table
Here is my situation: I have a solution with three projects: 1) Silverlight App,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.